Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pi controller with pic?

Status
Not open for further replies.

seyyah

Advanced Member level 2
Joined
Oct 7, 2001
Messages
646
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,298
Activity points
6,233
pic pi controller

How can we implement a pi controller using a pic or in pic?
 

pid controller using pic chip

you can structure a pwm to switch a fet via a driver transistor or fet

or you can get several devices from for-instance microchip
the tc 4429 is a good device and will give 6 amp fet driver

single channel

the additions of routines to send details to an lcd

or using a structured lanaguage for pic like ccs
will ensure you get the routines too all adhear

so you can adjust it via a few buttons or a rotory encoder shaft device

i dont want to polute your train of thought with code not designed for your task

best is write a flow charted bit set routines via byte port addressing bite the bullet get the software and do it
in a few nights at the pc

learning as you go... and traversing the mplab datasheet for the pic you use to get any functions descriptions you dont know fully
8)
I have prepaired in proteus a design file
for your controller
or to show you the method

the design will open with sp3 version
and has three sheets

notes:

if you use a pic 87x you can use the built in a/d and a pot to control the steps

but buttons is fine and pic84a's are cheep...

if you want rotory encoder details you need three pins in total for most type's
its like a mouse insides in many ways but gives incremental steps to be counted etc .. by your code

to give steps taken

the code its self is pretty straight foward with any c type lanaguage
and the display simple

my advice is to get some working code of your own making and build up adding features as you do each progressive surgery to your own code

this way the story stays with you a long time
and its easier for you to read thru

you can use coils instead of electrode's

for a pic youll get to a min of 2us or 1khz freq >= 100hz or soas a kind of normal frequency range expect a code to give 10us - ~us mark to space for 5050 duty
but you need to ramp the space and the mark to change the relative switch on time
perhaps just extend portA to give more i/os for control buttons
or use combinations of button press to activate other changes
forinstance press and hold the step till you indicate on the lcd that the mode has change using up and dn button gives space adjust instead of mark
this is one method and prob the easiest


or the lcd you can use the cgram to display progressive block sizes for a given space or mark setting much like a bargraph
this task although it sounds hard is realy realy easy
using c languages like ccs or hitec or gnu free version
most will happily drive all parts in the design
and will have drivers for the lcd you just define the pins

so planing a coil for these freq is looking at metal detectors
this topic is too big to descuss in this post



please provide other info like pi i take you mean pulseinduction

if so this circuit as is fine

I have added a third sheet
to show you how to drive coils
as i had only given electrode's {for use as a vapors gen or as an electro plating device}

the coils themselfs are easy to make from .51mm or .71 mm wire

if you need a bigger field use 1mm wire but warning the resistance is lower so you need to x3 the relative turns
but becouse the resistors are there this will protect the fet... and the resistor before the fet protects the chip
and fully saturates the fet every fire....


the resistors neer to the coils {sheet 3} are 2 watt carbon or carbon film {not metal oxide these vaporise... so be carefully}

finaly
I ADDED A SOFTWARE FLOW CHART
as a sheet 4

you will see the only interupting factors are the buttons themselfs or the start stop
the rest is a loop and a word value for adjustment of the pwm from increment decriment
and why you do this
you need to decide
if you want to keep the pwm "sort of running" when the up dn control's are pressed,
but my view is to make an accurate display and only allow pwm to run when start is pressed if another button is pressed it will stop too allow adjustment then start again {or wait for start stop{again you can add a mode for this using button detect routines and combinations of qualifying events to trigger functions }

perhaps pressing pwm1 2 together with start/stop will be a good
step for starting both at once or stat/stop issues one at a time depending which is displayed by pwm1 2 button
an easy solution....
this will also fully avoid blowing the fet or any false triggers or other issues of safty
as you can add a safty stop button very easy to the step x2
as this will then also stop it dead.....
if you add an inclussion that turns off the pwm to both pwm outputs if that button is detected

the rest is easy to do just makeing some simple c routines up
to print to the lcd at the right places and also to drive the pins for pwm and the buttons scanner,,,


files below has also a second version
to show a second chip driven on interupt on the b port of a second pic84f
this chip is set to d/a mode on the analogue port to allow for coding of the regulator supply rails
to nesesitate the power level and "field intensity" of the coils adjustment

or it can be used to run a management routines for a pwm electroplate system
it can talk in both directions easily
using a chalange routine then the first chip can wait for the reply data from the second
bit like a pair of schmit triggers


and a third version to show a slave core for pwm just interupt driven from i2c data from the main chip also on int incase you want also to give the pwm intination {changed pulse position} cpp modulation
i also adjusted the block diagrams




other things :
you can replace the words up/dn with wider and narrower

for the button names
as it is just the mark you are adjusting in the waves mark to space ratio these they can just be a binary ramp using a byte or an array of bytes to give the freq and relative ramp disprapotional mark space desired .... depending on the duty cycle you need

i also see your a new ish member
to get a demo of proteus vsm
that you can view the circuit in
use this url pasted to internet explorer with tt added for **
h**p://www.labcenter.co.uk/download/prodemo.exe

attached is also a library with other microchip trigger devices i found at vsm.libs site
 
  • Like
Reactions: linss

    linss

    Points: 2
    Helpful Answer Positive Rating
implementing a pid controller on pic

Thanks but i coludn't open your files because they were prepared with a newer version than that of mine. I have 6.1 version. Dou have any suggestion?
 
  • Like
Reactions: linss

    linss

    Points: 2
    Helpful Answer Positive Rating
simplified pid control pic chip

if you read the text above

download the demo
 

demo for pid controller in field

hi master,

this quit improve version of your old design i releay like it,

but i think you still working on code of it

regards
Fragrance
 

pi controllers with pic c

fragrance
obviously you didnt read the topic
and blindly posted any old rubbish

ONLY post usefull info

if you read the conversations i was having you will see i am helping by NOT giving code

only as asked for a design

nothing more
and therefore require no other input
or remarks


if code is required
it is very easy to write
i think if i remember it is 387 lines for all three cores
the biggest is the main core

this idea isnt new just a design i knocked up to do the task from a design i found on vsm.libs site
 

pid controller using pic

After i got the program, read your message carefully and examined your design, i see that there is a misunderstanding. I mean for pi; proportional/integral. May be i should have said "pid" instead of pi. Sorry for the confusion
 

pic pi control

seyyah

You can find some of interesting application note over Microchip pages.
For instance, try to see application AN532 and download pdf file at:

**broken link removed**

It is a Servo Control of a DC Brush Motor using PID. The asm source is given in the document, so you'll have an idea how to implement it for other Servo controls.

At Microchip index below you'll find also many other samples that I'm sure will be useful for future problems or need you should solve.

**broken link removed**


Hope helps
 

hi i am working with PIC18a4550 i want C program code for PID controller for my inverted pendulum system
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top