29 Jul 2005 marcin   » (Journeyer)

Not too much excitement this week generated by success, as failure has certainly had the upper hand. I've started a resign of the electronic system by listing the peripherals that I'll want in a typical robot (not just the current one) and mapping that to the uC peripherals (timers, etc) that are available. For example, differential drive (independent PWM to each motor) will take 2xtimers(w/PWM) and three GPIO. Controlling the SRF04 currently looks like it needs 2 timers, etc. It's looking promising - contrary to a previous post, the M16C that I have has 11 timers, although the pins for these timers are shared with other peripherals (eg UART). So there is a bit there to be allocated, which is nice.

All that software subsumption architecture stuff is really application programming and more in my expertise, it's doing the device drivers that is making me insane. I'm trying to do the code for the SRF04 (pulse out, measure width of pulse coming back) and I can't get the thing to work - most of the control code is in interrupts, so it's a bit hard to debug, but from what I can see, the SRF state machine (INIT->READY->TRIGGER->TX- >MEASURE->READY) has some issues. Most notably, i check that the state is SRF_READY before doing the trigger, and the check is with a function call that simply returns 1 if the srf_state == SRF_READY. It never gets past that, even though I know that the interrupt that puts it into the ready state does fire. Very frustrating.

If anyone would like to teach me a lesson, and show me how it's done, you can find my code here . Help or hints would be appreciated.

Also, for some reason, I can't get sprintf to work in my code, which is really strange since I have previously used it in other projects. It compiles happily, but the runtime just does wierd things -> so that makes reporting the range of the SRF that much more difficult. (I use sprintf to generate the character string for display to the LCD).

Nothing worthwhile was every easy. I just have to keep telling myself that.

Have a good weekend. Marcin

Latest blog entries     Older blog entries

Share this page