How my cat stopped being afraid and loved Arduino

    Hello, Habr!

    Recently, with a respected ja, we were thinking about which heading might be considered ideal for Habr - and you already understood what conclusion you came to. True, unfortunately, in fact, we do not have a cat, however, I promise to open the Arduino theme a bit below.

    However, we have different global news: Black Swift not only went on Kickstarter, but almost collected the required amount over the first 6 days.

    This is not a lot and not a little - there were projects that collected 100% in a day or in an hour, there were projects that died like that, barely reaching 50% over the entire period. We found ourselves in an interesting situation - on the one hand, Black Swift evoked mostly positive feedback in professional communities, on the other hand, the media of a more or less general direction were not interested in us - some other microcomputer, there are few of them - so some massive there was no surge in the first day or two.

    Here, of course, it was worth a little refinement before launch: to create some kind of senseless, but understandable and giving beautiful pictures and headlines expansion board that ordinary media would peck at. Well, for example, "the smallest router in the world" or "100% compatibility with Arduino." It’s pointless - because if you need a router, it’s easier to buy a ready-made one, but if you are really worried about compatibility with Arduino when you see a 400-MHz processor and OpenWRT, then Yun. But, as practice shows, all those journalists who traditionally contemptuously speak about marketers are very good at catching such simple marketing tricks.

    However, I’ll write more about working with Kickstarter later, when there will be an official 100% news feed, but for now - about arduino (actually not).

    I already mentioned a couple of times that when paired with Black Swift it’s convenient to use some cheap and uncomplicated microcontroller - AVR, PIC, STM32 - to implement hardware PWM, ADC and honest real time on it. Obviously, one inconvenience arises - the controller needs to be programmed separately, and if we aim at people who are not necessarily seriously versed in microcontroller topics, then this becomes a problem.

    Fortunately, under Linux there is an avrdude package that can do one very good thing - to program an AVR connected to the normal input / output ports (GPIO) of a Linux device. OpenWRT is the same Linux, side view, so building avrdude for it is, in general, a matter of technology and one small patch.

    Test board:

    It has an ATtiny24A, 8 MHz quartz, a small power cable, Black Swift connectors and a pair of IDC 2x5 connectors. Such a form factor did not pursue any specific goal.

    With installed Black Swift. One of the things for which I like it is the ability to put it on the connectors, and place any additional components under it; even above quartz (ordinary HC-49S) there is a bit of free space.

    The circuit is extremely simple: the tinky SPI interface connects to the Black Swift, its RESET interface also connects to one of the GPIO's and is simultaneously pulled to the power supply by the resistor. Tinka is powered for simplicity from 3.3 V, issued by Black Swift'om.

    Schematic in PDF , Schematic and Board for Diptrace and Gerberas.

    This is obviously half the job. Now we take fresh avrdude-6.1, slightly correct it to build under OpenWRT, for the future we add support for hardware SPI by Kevin Katzner , write Makefile and put it in a ready-made package.

    Patches and Makefile can be found here , and the finished package for OpenWRT 14.07 is here . It is not sharpened under Black Swift in any special way (in particular, I did not rewrite the linuxgpio driver from slow sysfs to fast direct access to GPIO), so it will work quietly on other boards as well.

    We try (avrdude -p t24 -c linuxgpio -t): The

    chip signature is correct, everything works. We flash the AVR to blink the LED:

    We blink the LED, just like on an Arduino.

    Obviously, it is easy to organize data exchange with AVR through the same SPI through which we requested it - send commands and parameters in one direction, and receive some data in response. That is, we fully integrated AVR with Black Swift, and so that we do not even need an external programmer - Black Swift can configure and flash a virgin chip.

    Of course, Black Swift can also be used as a programmer itself - with Wi-Fi access and the possibility of autonomous power. I even see how to bring it to the finished product: add a [disconnectable] translator of 3.3 / 5 V levels and make a web interface with a fusion calculator (there are some on JS) and upload the HEX firmware file. I even just had a suspicion that I myself would do it.

    If you wish, I suspect you can even compile gcc-avr for it, so that the firmware can be built directly on it, but somehow I do not see any practical need for this.

    Well, about Arduino: in principle, nothing prevents you from writing them to AVR HEX files received from the Arduino IDE.

    Upd. Jay demands to refute the dirty slander and say that he has a cat.

    Also popular now: