Showing posts with label PIC. Show all posts
Showing posts with label PIC. 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.

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

Thursday, 5 August 2010

Arduino or PIC?

A dilemma: what should I use? Should I buy into the ready-made hardware, tons of examples and accessories of the Arduino or do I stick with the more powerful/flexible PIC, which I've used before, which has a rich selection of peripherals and can make a smaller, neater end solution, but needs a lot more effort to get going?

The trouble is it's been a while since I did any serious PIC work and I'm attracted to the quick and easy Arduino. But I'm also not sure the Arduino will be up to scratch, with respect to I/O, peripherals and physical size (I could get a Nano?) and I'd have to learn a new platform.

So if I go for an Arduino, will I have to re-do everything in a PIC solution later? Should I go straight for a PIC solution, but with the extra time and effort?

I don't know. The Arduino does look like a quick solution...

Arduino website
Microchip PIC website