Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PID using a PICf16877 and ASM

Status
Not open for further replies.

dsc

Member
Hi everyone,

anyone here tried to create a PID controller based on a PIC16f877 (or any other PIC) using ASM? I'm currently planning to use simple hysterisis control, but would like to switch to PID later on. The thing that worries me is handling floats and bigger numbers using 8bits.

Perhaps I should just switch to a 16bit uC and C programming instead to save some time? the only issue with that would be having to re-write the whole interface code, as the PID is pretty much the only thing that I have to add.

Would appreciate any feedback.

Regards,
dsc.
 

Diver300

Well-Known Member
Most Helpful Member
You are not going to need floating point arithmetic. You can just decide on the scaling as you program.

There are plenty of maths routines (PIClist, Microchip PIC) for 16 bit maths in ASM.

18F series have an 8x8 multiplier

24F series have a 16x16 multiplier and divide support

but if you don't want to change the rest, a 16F877 should be fine for PID
 

dsc

Member
Hi Diver,

thanks for the suggestions.

Actually yes I can stick to whole numbers, the only problem being the big error sums and negative numbers for the errors. Will see what I can come up with.

To be honest I should have given more info about the solution I'm creating. The PIC based system is suppose to gather pressure samples over a period of 30s and then recreate the same pressure profile using a DC controlled pump. I've got a pressure transducer hooked up to the system to measure pressure and I'm using a pot to set the pressure during the 30s period of time. I've decided to use 500ms as the sample period, but of course when recreating the profile it's quite hard to do it smoothly. I was thinking of using a PID algorythm with a 'changable' setpoint (sample values) to do this, but if the PID is too slow it will not work properly. I was also thinking of interpolation, but it seems like I will need quite a lot of calcs for it and if for example two sample are close to each other value-wise it won't work smoothly anyway.

Any other suggestions on how to solve this issue (other than gather more data)?

Regards,
dsc.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top