Pinnovations logo

Development Log - June




 

<< Prev  Next >>

June

June 8

Lots of problems over the last two weeks. Received 3 new 18A Picaxes from Peter Anderson, along with 7805 regular, diode and resistors. Wired up the new Picaxe on the new breadboard, using Peterís power supply.

Picaxe worked good. Occasional EEPROM error messages but easily overcome. Reset button worked good.

But then as I hooked up the 74HCT138 and 74HCT240 chips, problems started again. Picaxe would not reset at power on, and would not respond to the reset button.

But, on power off I could see the LED flash indicating that it was resetting! That was my clue that I had a power problem and that the Picaxe was not dead.

Lots of experimentation. Sometimes it would be dead but if I probed it, it would initialize.

Eventually I found that if the serial cable was unplugged, all worked pretty well. With the serial cable in it would fail.

I wired up an on/off switch for the 5V supply out of the regulator. This allowed me to ensure that the power supply was stable before applying power to the Picaxe. Also switching power off at shutdown prevented the resets using the power of the draining caps.

My reset pushbutton was also flaky and replaced that with a heavy duty wall switch too.

Further tests showed if I disabled serial pin 3 (serin to Picaxe), then the Picaxe would initialize ok. Also found if I unplugged the AC adaptor for the laptop that the Picaxe would initialize ok. So that had me thinking of grounding.

Verified that the AC outlet was wired correctly.

Tried extra 22K resistor on pin 3. Picaxe would init but download would not work. Extra 10K resistor instead did not work at all (no Picaxe reset).

So I gave up and put an on/off switch across the serial in connection line. I switch it off to power up the Picaxe, then switch it on. Downloads work ok. I truly believe the Picaxe interpreter code has flaws in it, but I donít want to post that publicly.

Today I see where guys have added Schottky diodes to this line to prevent problems with A to D conversion lines. I smell something fishy here ...

Getting ready to build my lamp matrix. Did basic lamp testing (as I had done with the Stamp). The Picaxe is slower so there is a bit of flicker. But for the more advanced Picaxes, you can use a faster external oscillator to speed it up. I tested a TIP102 transistor last night to record the current draw and make sure I can hook it up to the Picaxe ok. With a 4.7K resistor it only sucked .8ma.

I will build a physical 2 x 2 matrix and test with my live code, which supports 8 x 4. When that works I might then try to hook up to Solar Ride.

I still believe the matrix is the best way to go. For 8 X 4, I can use a cheap Picaxe. Chips/transistors used amounts to:

  • 1 - 74138
  • 1 - 74240
  • 1 Ė 2803
  • 8 Ė TIP107
  • 4 Ė TIP102

For the "linear" arrangement, which is simpler conceptually, I would need:

  • processor with 13 output pins
  • 4 Ė 74138
  • 4 - 74240
  • 4 Ė 2803

The idea here is you need 3 address lines for the 3-8 decoder for each 2803. Plus one extra line, split into 4 to go to the 74240 chips to turn the output off (Z state).

The chip cost for linear is lower except for the fact that you need a bigger processor. You would need to strobe all 4 2803s in parallel so that your duty cycle is about 1/8th (e.g. 125Hz with no flicker in theory).

Also if you scale to 64 lamps, the matrix solution starts to look way better. All that would require is 4 extra output lines and 4 more TIP102s. The linear solution needs 33 output pins, plus 12 more chips.

I guess there is also the question of the reliability of 2803 chips driving 250ma bulbs continuously. Seems within spec but there is no heat sink possibilities, etc.

June 18

Managed to build my 2 x 2 lamp matrix a week ago. Just put four #47 bulbs on some pag board with enlarged holes and wired it up. First surprise when I hooked it up to 6V just to test continuity was that there was leakage. One bulb would be bright but the other 3 would be barely glowing.

Then it struck me that there were circuits through the other three bulbs, with the bulbs acting like resistors. So I had to add diodes. Bought some 1N4148s for this. They have a forward voltage drop of about .5V that is not too bad.

This simple activity was very frustrating, as twice I wired the diodes up wrong, meaning I had to de-solder and re-solder some wires twice. Ugh. Anyway, with diodes in front of all bulbs, I saw no leakage.

Build my matrix circuit with TIP102s and TIP107s. Worked good. Terrible flicker initially. Then I used "setfreq m8" to increase Picaxe speed to 8mhz from 4mhz. Flicker was still present but greatly reduced. So wonderful to add one line of code and see speed doubled!

Optimized the code and in-lined a subroutine to reduce instruction count. The result of that was minor flicker at 4mhz and absolutely none at 8mhz. Very happy with that.

Next on the list was to hook up the BS2 to the Picaxe for sending serial commands. I made a couple of 2 wire connectors with .100 terminals and housings. One connector will be a 5V power jumper from one breadboard to the other (so both BS2 and Picaxe share same power supply). The other will be for the two input/output lines from BS2 to Picaxe. Put 4.7K resistors on these two lines to limit current passed.

Hooked up Stamp to Picaxe last night. Kind of awkward to test but at the end of the night I twice managed to send a one byte command to the Picaxe and have the interrupt handler process it correctly. Had messed up baud settings for quite awhile. Both sides need to specify inverted mode. The other thing I initially forgot was that at 8mhz speed, you need to specify baud as 1200 on Picaxe (but itís really 2400).

Still very awkward with power and resets. If I had power to both the BS2 and Picaxe, the Picaxe would not reset but the BS2 would. So then the procedure was to unplug the BS2 so the Picaxe would reset, then plug the BS2 in.

But, if I had the Picaxe editor open, the BS2 would not init if download cable connected to BS2. Closing the editor solved that. Must have had the serial port open or whatever.

Other goofy sequences too that I can't remember.

The strangest thing was when the Picaxe was not powering up, I went to touch the logic probe wire to the Picaxe. Just waving the probe in the air over the Picaxe caused it to reset!!!

Now I can try more comprehensive tests for sending data. The other problem is Picaxe memory is maxed out so I can't even add 1 instruction without deleting another. If I hadn't had the stupid Picaxe problems before I would have already ordered the 18X with more memory.

I will try sending multiple commands to the Picaxe, some requiring multiple bytes. I need to work on the timing of the interrupt pin pulsout and pause time before sending the command.

Also bought a Tektronix T922 oscilloscope on ebay yesterday. Found a free PDF version of the manual too which is great. Hoping to get that and see how much ripple comes out of my power supplies.

Installed ExpressPCB software, not so much to be able to layout a PCB but for the schematic software. Looks better than most other schematic software Iíve seen (which costs money).

oscilloscope testing

Using the Tek T-922 on the Picaxe breadboard. So many power problems so I wanted to see the power line noise.

June 21

Started drawing lamp matrix schematic with ExpressPCB. Didnít get too far, but it looks ok so far. Over the weekend worked on the lamp matrix code and communication with the BS2.

Testing was very successful. Changed the command to set the state of an individual lamp. Instead, just supply the lamp matrix byte containing that lamp. Processing goes from 10-11 instructions down to one. This makes interrupt processing much faster and reduces the program size. Down to around 200 bytes, so that gives me room for diagnostics or to implement an attract mode.

Also tuned the BS2 test code to see if I could keep reducing the length of the interrupt pin pulse, and the pauses required for synchronization.

First got all working with pulse of 2.5 ms and two pauses of 5ms or more. Got it down to {2.5, 3, 3} then further reduced it to {1.25, 2, 2}.

Added test code so you could visually watch the flicker as commands are received. For a full set matrix command (5 bytes), the flicker is fairly noticeable. But you only need to send this command infrequently.

For a single byte command flicker was not bad at all. Noticeable for a 2 byte command (most common), but still ok.

Got comm speed up to 4800 baud from 2400. That helps a lot too.

Now going back to Java pinctrl code to update lamp controller command definitions to match what is actually implemented in the BS2/Picaxe.

Also worked a bit on the actual BS2 controller code to handle the Picaxe commands. The next thing will be to try an end-to-end test from pinctrl to BS2 to Picaxe. It will be fun to turn lamps on and off from the PC.

Also must note the continuing goofy Picaxe start up problems. Had some BS2 problems too but that was due to the flaky 2 wire jumper from breadboard to breadboard. One of my connectors is not good, so the BS2 board would lose power sometimes.

Here are the power-on sequences required and notes:

  • If both the BS2 and Picaxe are powered up together, the Picaxe will not reset but the BS2 will.
  • If the BS2 is unplugged, then the Picaxe will power up. The BS2 can then be powered up.
  • With both Picaxe and BS2 powered up as above, comm may still not work until Picaxe manually reset. This may just be the Picaxe waiting on a serin command in the interrupt handler.
  • Sometimes the Picaxe comes on first time, but usually it must be powered off/on 3 times to work (didnít Dorothy have to click her heels together 3 times to get back to Kansas?).
  • To download code the BS2, the Picaxe IDE must be closed. In fact I think the BS2 will not initialize if connected to the download cable and Picaxe IDE open. You close the IDE and the BS2 initializes.
  • Picaxe still requires the on/off switch off to serial in line of download cable in order to power up. Can be on after that.

The hang in the Picaxe code as noted above may be due to waiting in interrupt handler for serin. But that shouldnít be. I may try and add diagnostic code to see what it is doing.

Failing that, it is probably a good idea to wire a BS2 output pin to the Picaxe reset pin. BS2 can then control Picaxe resets.

Forgot to mention that last week I ordered two "scratch and dent" BS2p24 modules from Parallax. $40 each (regularly $80). These are 3X the speed of the BS2, more features, etc.

The plan would be to make one of them the master controller and use a regular BS2 for switch matrix. Weíll see.

June 23

Working on the PC Java code again. Rewriting the lamp command support to match what I actually implemented in the Picaxe controller code. Also had to finish writing the LampMatrix class code. Needed methods for easily working with the actual byte array of matrix state.

Have that pretty much done so now I need to go to the BS2 and update itís code to translate the PC commands into Picaxe ones.

June 25

Had more success last night, hooking up the PC to the BS2 to the Picaxe and sending lamp commands end-to-end. Very pleasing. Spent a few hours the last couple of days updating the PC Java code to get the correct lamp controller commands set up. Also added some convenience methods although I still need to add a couple more to make setting lamps painless.

Still need to further test sending these commands, e.g. stress testing. Also updated the BS2 and Picaxe code last night to get them in synch. The BS2 code for passing commands through is pretty simple.

Also I will create a Java test/diagnostic console. This will just be a standard command line dialog using simple text commands to issue all micro controller commands. That way I can turn lamps on and off at will, display matrix state, etc.

I will also be able to read command scripts from a file, so I could play little light animation sequences.

<< Prev  Next >>

Last updated: September 26, 2008

   
 
 
 
 
 
 
 
 
 
 
 

 
© Terry Cumming, 2004-2008