need programming help pwmpal
sport270
Posts: 82
I have a commercial automation system i am bringing online. I am in a EXTREME TIME CRUNCH.
I just need some help finding programming code to test and see if a bs2 or bs2 / pwmpal will handle the hydraulic control circuits i am needing to setup.
I am currently using in house built proportional hydraulic controls. I need to update this control for a new application.
I need three PWM signals one example is : 210hz 56.9% duty cycle. 4.62v dc
the preferred hz is 100hz. and need the duty cycle to be adjustable with pot or programming.
Also need to read 3 incoming signals that are from the shafts that the pwm signals are controlling. and display these rpms on lcd serial display.
would also like another mode possibly, that would read signal & change PWM duty cycle to keep shaft rpm at set speed.
If anyone in your organization can help with this problem please contact me asap Thanks,
Jeff Kirk
Farm Enhancement Systems
Lubbock, Texas 79416
806-767-0715
sport270@yahoo.com
Ps... I noticed you have other chips and options available, I am not set on just the bs2 or pwmpal, just am familiar with programming them in past projects.
And i have no problem with paying for programming & or hardware help, but need to atleast have a test unit in next 24-48 hrs....
I just need some help finding programming code to test and see if a bs2 or bs2 / pwmpal will handle the hydraulic control circuits i am needing to setup.
I am currently using in house built proportional hydraulic controls. I need to update this control for a new application.
I need three PWM signals one example is : 210hz 56.9% duty cycle. 4.62v dc
the preferred hz is 100hz. and need the duty cycle to be adjustable with pot or programming.
Also need to read 3 incoming signals that are from the shafts that the pwm signals are controlling. and display these rpms on lcd serial display.
would also like another mode possibly, that would read signal & change PWM duty cycle to keep shaft rpm at set speed.
If anyone in your organization can help with this problem please contact me asap Thanks,
Jeff Kirk
Farm Enhancement Systems
Lubbock, Texas 79416
806-767-0715
sport270@yahoo.com
Ps... I noticed you have other chips and options available, I am not set on just the bs2 or pwmpal, just am familiar with programming them in past projects.
And i have no problem with paying for programming & or hardware help, but need to atleast have a test unit in next 24-48 hrs....
Comments
http://www.parallaxdirect.com/cart/catalog/Parallax-28020-PWMPAL-202.html
You'd need a timebase for counting the shaft RPMs. A 32KHz crystal and CD4060 clock oscillator / divider (see datasheet) would give you a 1/2 second clock (or other submultiple) that would be fed into the PWMPAL's 4th counter channel. That way, you could read the 4 counters all at the same time and it would give you the shaft counts and the time. You could subtract the previous counts then divide the revs by the elapsed time then multiply by a fixed scale factor to get RPMs.
Note that the PWMPAL is now made and sold by ParallaxDirect.
on either the bs2 or pwmpal..... just to test
The reason for suggesting a separate timebase for measuring RPM is that the Stamp has to stop doing other things to measure time. You can use the PWMPAL to count all 3 pulse sources by zeroing the counters, PAUSEing for a specific amount of time, then reading the counters from the PWMPAL. The PAUSE time has to be adjusted for the amount of time it takes to send the "!PWMC0" command to read the counters like this for a BS2sx or BS2px ctrs would be defined as an array of 4 words and T19K2 would be the Baud constant for 19200 Baud.
The above would tie up the Stamp for 250ms and read 1/4 the RPMs so you'd have to multiply them by 4 for display.
You could read the pot values using an RCTIME statement, but you'd have to choose the R and C values so that the RC time (and RCTIME execution time) wouldn't be too long. You'd want to keep the time well under 250ms, particularly because you've got 3 pots to read. You probably want to keep your control loop (read RPMS, read 3 pots, update RPM display, adjust PWMs) under 1/2 second so it seems responsive enough. You could speed up the control loop by adding a simple 4-channel ADC like the MCP3204 to read the pot positions as analog voltages rather than using the RCTIME statement. There's example code on that webpage. You could also use an ADC0834.
For the immediate need of testing and alleviating my customer concerns, could you help me with a simple program to duplicate this output. 210hz 56.9% duty cycle 4.62 vdc ... and possibly have a ramp up over 2-3 seconds. And is it possible to have a serial lcd 4x20 display also connected to the stamp that is also connected to the pwmpal?
preferred 100hz signal but can have 70hz to 300hz i think
1800 ma max draw at 12vdc
nominal coil 3.66-4.52 ohm
inductance of 33mh
shaft speed is 630 hz / rpm 60 tooth gear
As has been pointed out, using an external PWM controller and maybe pulse counter is the only practical way to get the Stamp to be fast enough to both measure the speed, adjust the PWM and display the output of three channels. It can be done with the parts you've mentioned or you could consider a controller with some of those features built-in.
i need to somehow duplicate one pwm signal for test purpose, it needs to duplicate what my proportional controller was outputing as a start point. 4.62 vdc, 210 hz @56.9% duty cycle on a Irf540
i just need sample code for bs2 or pwmpal for 1 output channel for test.
http://www.parallax.com/search?search_api_views_fulltext=PWMPAL
i already have a pwmpal, and bs2 related accessories. i also already have a inhouse built pc board with bs2 that was used in the past for load control. it already has all necessary buffers on input for rpm of shafts, and bs2 to ULN2003 TO Irf540 for output.
can i not rewrite some of the code and just let bs2 output simple pwm just for this test. and is it possible to redirect the rpm shaft speeds that i have displaying on debug screen to goto lcd screen aswell
http://www.parallax.com/downloads/pwmpal-documentation
Using the PWM directly from the BS2 is not recommended, since this PWM output is not designed to directly drive a motor. The reason is because the frequencies are too high for the MOSFET and while it may appear to work, the MOSFET spends too much time operating in the linear region causing excessive heat from the MOSFET that can be destructive.
this sample program is part of the pwmpal 28020 documentation. I need help in where or how to change the duty cycle with a pot
this sample program is part of the pwmpal 28020 documentation. I need help in where or how to change the duty cycle with a pot
Example 2 PWM Output with Hardware Control
This example uses an active-high pushbutton circuit to control a DC motor connected to the PWM
channel specified by the MotorNum constant. When the switch is pressed, the motor speed will ramp
from 25% (minimum speed to get test motor moving) to 100% (full speed). When the switch is released
the motor will stop without having to send a new speed value to the PWM channel. This program
shows how the BASIC Stamp microcontroller can monitor and use the control inputs.
When including code, use the CODE tag in the advanced edit. This will preserve indentations and such. You could also attach the code with the attachment icon, and it will be save as a zip file, (preferred).
http://forums.parallax.com/showthread.php/134682-Forum-Guidelines
Also, I went ahead and added the "code tags".
Thanks Dave, I was just getting around to include the coded tags. You faster than me.
How exactly are you doing that?
This part --
speed is the PWM'ing variable.
An application of RCTIME, the result of which would be used to "map" to a range of 1-100
DO..LOOP'ing an RCTIME every iteration would slow things down.
Do a button check and then GOSUB to an RCTIME subroutine.
Above post #27 shows how to take the number from the RCTIME statement and use it to adjust the duty cycle.