Wednesday 15 June 2011

Why are simple things so difficult?

Ok, I've got a couple or three hours to spend on a controller. I need to control an EDF (output a servo signal) and read a ultrasonic ranger (read ADC channel). Shouldn't be too difficult, right?

So I've opted to try it out on the mBed. First there's some faffing with usernames and passwords, then I remember the web-based IDE doesn't work on Opera. I finally get up and running.

Reading an ADC channel is dead simple and works first time. Cool. Outputting a servo signal should be just as easy. It isn't. I check the code (C++ is still alien to me) and libraries, jump through some hoops and then it compiles. Checking the signal on the scope shows it's not moving and this highlights the major drawback of the mBed: no debug.

No debug and my limited C++ knowledge leads me to dump the mBed and switch back to a PIC. It's getting late and I just want some simple algorithm to work, nothing fancy. I've got some bit-banging code working already so now just need to remember how to do an ADC read. I think I've done everything that needs doing, so I switch to debug mode and the value in the watch window changes as I twiddle the pot. Sorted.

Next I have to tie the ADC to the servo signal, but not now; it's late (or early) and I'm off to bed...