Showing posts with label servo. Show all posts
Showing posts with label servo. Show all posts

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...

Sunday, 16 January 2011

Happy bunny

I've actually managed to get something done! OK it's nothing major, but I feel I've accomplished something. Something I haven't felt for a long time, so I'm a happy bunny. All I've done is added three buttons; up, down and home, along with adjustable end stops and home position to my bit banging servo code. I also upped the refresh rate to about 80Hz, from previous experience. I can substitute an EDF and could set the home position to be just below the point where the whole thing gets light on it's feet.

But I need to close the loop, so will dig out the ultrasonic rangers and try remember how to setup the ADC to read the range signal(s). I know, it's going to very crude...

Haven't had any photos recently, so thought I'd change that:

Microchip ICD2, my own dev board and standard servo.