News:

Let's find out together what makes a PIC Tick!

Main Menu

How to Handle a PWM Pulse Train Into a Pic?

Started by Craig, Today at 02:39 PM

Previous topic - Next topic

Craig

My Daughters Treadmill sends a PWM signal from a Pic16F877 into a Pic12C508A, The Pic12C508A has Died so I have put the signal from the Pic16F877 into a new Pic16F886 running at 20Mhz Xtal, this seems to give me the best results using the COUNTER Command in Positron. If I look at the signal on a Logic Analyzer (Set For - PWM and Timing) when it starts it gives 5 Pulses {Rising Edge to Rising Edge} then a 3.2 Second delay with 3 Pulses then a 1.6 Second delay with 3 Pulses this is for a BASIC Start at the slowest speed. If I start using the WALK Speed it gives 5 Pulses then a 3.2 Second delay with 9 Pulses then a 2.6 Second delay with 9 Pulses. This changes as the Speed Selection changes from Walk to Jog to Run and So on but, the Start Command Always remains at 5 Pulses to show a Start Treadmill PWM.pdf .

The first problem I am having is that the sequence of numbers on the COUNTER Command in Positron Changes If I do a basic start and look at the Data on a Serial Terminal program. The first time I do a start it will give say 1110110000... the next time I do the same start it will give 1010110100.. etc and so on for the First 5 Pulses and does the same with the other Pulse strings, If I look on my Logic Analyzer at the same time {The Logic Analyzer always looks the same and gives the Pulse train correctly each time}. I have gone from a 18F27Q10 device running at 64 MHz And CDIV = 1:1 (Too Fast) then to trying it at 4Mhz And CDIV = 4:1 which is (too slow) then I decided to use the 16F886 @ 20Mhz which seems to be fairly close but, still seems to be out?

My second question is how ho I handle this PWM Pulse Train Sequence coming into my PIC? Should I push it through a Op Amp and then Into the ADC on the Pic to see the desired speed that I need to Drive the motor at or should I try and decipher the pulse train to see the desired speed that I need to Drive the motor at ?

The Problem with the Speeds as they get higher like JOG and RUN they are Pulsing with Very Similar PWM Pulse trains in other words they are very similar {The PWM Train and Delays between the Pulse Trains}

Any help is very much appreciated!

Craig