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

Thursday 10 February 2011

The path of least resistance

I got to play with an mBed at work yesterday, it's pretty awesome.

I'm in the process of designing a small PIC board that I can stick a number of different footprints on to take a range of devices. I was going to allow flexibility for plug in expansion (like the Arduino shield) but still keeping it small and simple, and being compatible with breadboards. The plan was to use it on the UAV and a couple projects for my motorbike.

I wasn't happy with the cost of the Arduino. It's too big and expensive to leave in many simple projects (especially if using shields). The smaller versions have no on board USB, which means more faffing. There is a slightly bigger version that does have USB on board, but that's only a few £ less than an mBed and doesn't do USB host, CAN or Ethernet (unless I'm mistaken).

So I'm going to simplify my PIC board, for simpler projects, keep it smaller and cheap (10+ for the price of an mBed?). When I need USB/Ethernet/CAN, I'll use an mBed.

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.

ICD2 sorted (& plan B?)

Got it working last night by uninstalling MPLAB 8.6 and MPLAB X, then deleting the microchip folder. Installed 8.63 and X again, went through the driver installation and it connected!

So now I can mod my bit banging servo code for controlling an EDF.

But wait... thinking about it last night, there's no point doing all the low level stuff in the uC, that's just going to delay things even further. I need to use an external servo controller that I just talk to over serial comms. It takes a lot of overhead away from the main processor and makes servicing each task a lot simpler. Sound like a plan?

Friday 14 January 2011

ICD2 is OK

Plugged it in, had to install drivers, but MPLAB connected to it fine.

Is it a Win7 problem?

Still no luck

Last night, I tried reinstalling ICD2 drivers, which didn't work. Then I downloaded and installed MPLAB X (Beta), no change. I can only assume my ICD2 died since I last used it!? Then I got bored so went and watched four or five episodes of The Big Bang Theory (thanks for the loan, Gary).

I'm going to take the ICD2 to work today and try it on my machine there.

Wednesday 12 January 2011

Been too long!

I have a little time before my studies start up again, so thought I'd try to get something together to control an EDF for crude testing. I grabbed my PICDev01 board, ICD2 and a PSU and sat down to get to grips with MPLAB IDE again (it has been a long time).

So far I'm not having a lot of luck. It's nothing I haven't done before; I think the ICD2 drivers haven't installed properly and the project won't build (new HDD since last used too!). I can see the advantage of having everything in the cloud, as the mBed does; saves these sort of setup hassles...