Jack Crossfire's blog View Details
Archive for February, 2015
Posted by Jack Crossfire | Feb 28, 2015 @ 05:59 PM | 8,038 Views
It's 10 years late in the making, but now the Arduino nuggets not available anywhere else because no-one talks about the flaws in their own investment or they just don't know. The ATMega328 has a lot of performance not available in the default Arduino load.

The Arduino sketch is preprocessed into a C++ source file of some kind, which is linked into a main program in hardware/arduino/avr/cores/arduino. There are convenience macros named sbi in the main program but named setBit in the sketch.



The Arduino IDE runs a bunch of commands to preprocess, compile & flash your program. It would be easier to run a makefile from the command line, but there's no easy way to extract the commands from the IDE. Running a program requires uploading then clicking through to enable the serial monitor every time. The serial monitor resets it again.


There is no bit toggling opcode like there is on a PIC18. Toggle a bit with

bitWrite(PORTD, 2, !bitRead(PIND, 2));


Any project is going to finish as a standalone ATMega using its internal oscillator. The Arduino UNO is fixed to use a 16Mhz crystal & doesn't allow changing the clock source to the internal oscillator. This requires building up a 2nd board, using the UNO board to write a bootloader on the 2nd board. The clock source can only be set with the UNO board programmed with an ArduinoISP sketch.

Fortunately, the internal oscillator's 8Mhz speed can be simulated by setting the CLKPR register.

CLKPR = (1...Continue Reading
Posted by Jack Crossfire | Feb 21, 2015 @ 02:55 AM | 8,946 Views




10 years after everyone else, it was finally time to get the Arduino going. It was decided that a totally silent fan can be made, using the motor in stepper mode, driving a continuous sine wave on all 3 phases. It wouldn't be very efficient, but it would be guaranteed to work.

The atmega328 has a huge number of PWMs, enough to drive 6 MOSFETs independently. Getting this number of PWMs requires locking them to the CPU clockspeed, so the CPU clockspeed needs to be adjusted. Completely independent frequency would reduce the number to 3 PWMs.

At 16Mhz, PWM goes at 64khz. Using the 8Mhz internal oscillator, PWM goes at 32khz. The clockspeed can be adjusted in powers of 2 & would have to be 8Mhz or below. Changing the PWM frequency also breaks all the features of the Arduino libraries, since they use the timers for other functions.

The rest of the required functionality is standard for microcontrollers, an ADC to control speed, an ADC to detect stalls.

The mane problem is the arduino IDE offers little to program a bare atmega in a circuit. The IDE can't program an atmega without a bootloader. It requires connecting the bare atmega's SPI pins, programing the Uno's atmega to program a bootloader into the bare atmega, then connecting the bare atmega's UART pins, removing the atmega on the Uno to program a main program on the bare atmega. This has to be repeated for every bare atmega.

The IDE also can't write a new bootloader on the Uno's atmega. That requires buying yet another programmer & connecting it to the ICSP header on the UNO.

The IDE & Arduino libraries have more likely served their purpose in bringing up a PWM test program. The UNO has to be reprogrammed for programming bootloaders in bare atmegas. The bootloader source has to be modified to be a main program.
Posted by Jack Crossfire | Feb 15, 2015 @ 08:37 PM | 8,240 Views




A very brief test of path following was a complete failure. Machine vision did the business, but feedback was either too fast or too slow, never able to stay on the path. Maybe the machine vision was too slow. Line following robots have done this forever, but using very fast sensors.

Maybe the feedback needed low limits. Maybe instead of continually adding an offset to the heading, it needed to add offset once when the path veered 1 way & not again until the path veered the other way. Maybe the rate of change in the path is needed.

It's much more complicated than expected, for something that's just supposed to trim steering.

Anyways, either the battery was defective, never charged, or the PI sucked a lot more power than expected, but the battery went to 8.4V & the pi died. Then the 433Mhz died. It looked like a conformal coating issue. Managed to drive it home using the phone. There were signs the phone could have the same 1 handed interface as the stick & the phone could be reasonably water resistant.
Posted by Jack Crossfire | Feb 15, 2015 @ 02:02 AM | 8,089 Views
Posted by Jack Crossfire | Feb 13, 2015 @ 12:15 AM | 9,523 Views
After a sleepless night of using the travel fan, it obviously needed to be completely silent. PWM would never do. An ESC like none other needed to be built. It needed to use linear voltage control. It was finally a practical reason for the lifelong dream of building an ESC from scratch.

It needed to run on linear voltage down to 1V. It would be fed by a 6V BEC with some way of adjusting voltage without PWM. It would need all N MOSFETS, because the high voltage wouldn't be high enough to turn on a P.

There was technical appeal in making it out of BJT's. It would be the only one of its kind. There's a massive supply of BJT's in the apartment. They would take some voltage drop off the regulator. But to be a travel fan, it needed to be compact, so MOSFETs won out. There was still a massive supply of MOSFETs from the days of trying to launch spaceships with magnets & burning them up instead.





The 1st attempt was a through hole failure. It used P MOSFETS which would't turn on because the high voltage was too low. A more complicated circuit with N MOSFETS, a full boost converter, high side BJTs would be required.



...Continue Reading
Posted by Jack Crossfire | Feb 08, 2015 @ 08:32 PM | 8,373 Views

After a month of commuting, a new electronics package was fabricated. The $5 Turnigy BEC was put to use. It was a piece of garbage that melted at 2A. The high energy BEC business is a mercenary business. They only contain a few dollars of parts, but digikey has a $25 minimum. Castle creations remanes the only supplier of a functioning high energy BEC, still charging $25 after 10 years.

A rising edge interrupt handler allows any pin on the STM32 to be used as an SPI bus, at reasonable bitrates. Piecing together forum dialogs revealed a way to access hardware SPI on the raspberry. There was a workable test program on http://www.raspberrypi.org/documenta.../spi/README.md by the name of spidev_test.c


There was never an organized way to stuff the truck.

...Continue Reading
Posted by Jack Crossfire | Feb 01, 2015 @ 06:54 PM | 7,082 Views
A machine vision algorithm emerged, which could do a reasonable job tracking a path. The machine vision algorithm of choice goes at 3fps on the raspberry pi. The PI can only go up to 900Mhz. The RTL8188 is the only chip still supporting wifi access on it & it rarely stays connected longer than a few seconds.

The other problem is the algorithm only works in daylight, on a single uncrowded path near the apartment. When you have to commute 3 hours a day, you can't be home during the daytime, at all. There wasn't a chance to test it in January & probably won't be until April. There's no open space in the city to test it.

In terms of cost per clockcycle, the Odroid C1 has now been the duck's guts for several years. Development of the RTL8188 driver has continued on the Odroid, supposedly making it more bearable. It begins at $37, then the gauging begins in ernest, with exorbitant shipping, taxes, & cash only.

It makes no sense for so many middle men to now be required in payments, each adding on their own 2.5%. 30 years ago, there was just a bank. Now, it takes Paypal, Square, Apple pay, Google wallet, Coin, thousands & thousands of middle men. As middle men gauge more, new middle men emerge, promising to reduce the fees by spreading the cost of the lower middle men among a larger group. It was once said that Visa's exorbitant fees bordered on racketeering. Now, the current generation is in middle man euphoria, praising Google wallet, Apple Pay, & Square, which merely tack on other fees on top of Paypal, on top of Visa, on top of the bank. It's insane.