![]() |
Forum Index : Microcontroller and PC projects : PWM command hates me...
Page 1 of 2 ![]() ![]() |
|||||
Author | Message | ||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
Not having much fun here - PWM command does not seem to want to ramp-up and ramp-down a test motor, connected via a PWM H-Bridge motor driver. Here is the test code: 'PWM tester for 44-pin MicroMite '11/07/2014 SetPin 2,DOUT SetPin 1,dout Pin(2)=1:Pin(1)=0 Print "Ramping up..." For x=20000 To 100000 Step 100 PWM 1,x,50:Pause 10 Pin(2)=1 Next Print "Ramping down..." For x=100000 To 20000 Step -100 Pin(2)=1 PWM 1,x,50:Pause 10 Next End This is on a 44-pin MicroMite module.(from WW) When power is connected, motor just runs forward at full speed no matter what the MM code is doing. Any ideas? Attached is the PDF for the 6221 H-Bridge controller - I am using PWM control mode B. 2014-07-15_082344_BD6221F-E2_H-Bridge18v_SOP8.pdf Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
Opps - I think I have the wrong I/O pins - I am using physical pin1 on the WW 44 module, which I don't think is PWM controller #1.... ...testing.... EDIT: Yes, I was on the wrong I/O pin, I needed to be on pin 21(for the 44's) I am getting speed up and speed down now, but still not the range I was hoping for, which is fully-off to full-speed, and full-speed to fully-off. Tinkering continues. Smoke makes things work. When the smoke gets out, it stops! |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
Try leaving the frequency constant and adjust the PMW instead PWM 1, 20000, 5 ' 5% PMW Pause 1000 PMW 1, 20000, 60 ' 60% PMW Jman |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
Ahhhhh - cheers - will test. I might be using the command wrong....... @ jman - you are onto something there - if I vary the last paremeter, the motor slows up!!! Tink, tink, tink...... Smoke makes things work. When the smoke gets out, it stops! |
||||
BobD![]() Guru ![]() Joined: 07/12/2011 Location: AustraliaPosts: 935 |
Hey Groggy, you not on the plonk again? Bob |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
THANKS JMAN - You were RIGHT on the money there!!!!!! ![]() New code: 'PWM tester for 44-pin MicroMite '11/07/2014 SetPin 2,DOUT SetPin 1,dout Pin(2)=1:Pin(1)=0 Print "Ramping up..." For x=100 To 0 Step -1 PWM 1,20000,x:Pause 50 Pin(2)=1 Next Print "FULL SPEED!" Pause 2500 Print "Ramping down..." For x=0 To 100 Pin(2)=1 PWM 1,20000,x:Pause 50 Next End This code ramps up the motor to full speed, then ramps it back down again. This is zero-to-full-speed, then full-speed-to-zero. Works wonderfully - thanks. ![]() Out of interest, what was I doing wrong? Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
HAHAHA!!!!! ![]() ![]() ![]() ![]() Nope, not tonight, as I feel very embarrassed about that last thread!!! ![]() ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
Frank N. Furter Guru ![]() Joined: 28/05/2012 Location: GermanyPosts: 936 |
Hi Grogster, you have only changed the frequency, not the duty-cycle with your code. The frequency says how often your motor is switched on and of in a second but the duty-cycle says how long the motor is on or off in each cycle and thats make the speed. A higher frequency makes a smoother behavior of the motor but should not change the speed... Take a look to:PWM Frank |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6220 |
The controller chip has a minimum PWM frequency of 20kHz Your motor is likely to have a preferred frequency. You can usually adjust the frequency to get a 'hum free' motor which runs cool. Hopefully, that preferred frequency is within the range of the controller. Jim VK7JH MMedit |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
Thanks guys - I obviously was using the command wrong, and thanks to Frank for the clarification - useful information for me. The motor I am using is a gearbox motor, so extremely accurate RPM is not important for me, it is the ramp-up and ramp-down. I also plan to use the brake mode of the PWM controller, by setting both inputs high - this locks the motor. It is all tinkering towards my model elevator project, and this is the motor control for the cabin/counterweight hoist motor. I gave up last night before I got myself in another mess, but later tonight, I plan to add to the test code, so that the motor ramps up and ramps down forward, then ramps up and ramps down in reverse. This is done just by applying the PWM to the 2nd input, and the 1st one I was using - it is held high instead. SHOULD be painless enough, now that I am using the command correctly! Thanks everyone, and I will post back. Smoke makes things work. When the smoke gets out, it stops! |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
UPDATE - It is working fine in reverse now, once I worked out a couple of bugs in the way I was driving things..... 'PWM tester for 44-pin MicroMite '11/07/2014 Print "Ramping up..." For x=100 To 0 Step -1 PWM 1,25000,x,100:Pause 50 Next Print "FULL SPEED!" Pause 2500 Print "Ramping down..." For x=0 To 100 PWM 1,25000,x,100:Pause 50 Next Print "Stopped." Pause 2500 Print "Now trying reverse - Ramping up..." For x=100 To 0 Step -1 PWM 1,25000,100,x:Pause 50 Next Print "FULL SPEED!" Pause 2500 Print "Ramping down..." For x=0 To 100 PWM 1,25000,100,x:Pause 50 Next Print "Stopped - Test ended." End Smoke makes things work. When the smoke gets out, it stops! |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
Hey Grogster ! Now that you're a pwm-miester : Are there 4 separate pwm channels ? (both frequency and duty cycle independent) or 2 ? Seems I remember someone saying 4, but now, looking at the manual it says 2 ???????? |
||||
jman![]() Guru ![]() Joined: 12/06/2011 Location: New ZealandPosts: 711 |
So my understanding is 5 outputs Consisting of 2 separate channels Outputs on channel 1x have the same frequency but can have independent ratios Outputs on channel 2x have the same frequency but can have independent ratios Regards Jman |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
Agreed. Sorry I missed your post yesterday, hitsware - I was fully involved in the networking hell thread, and constant playing around there to see if I could get that working. The PWM motor control has been shoved to the side of the desk, once I had the concept working! ![]() Too many things I want to play with on the uM and MM, and not enough flippin' hours in the day!!! Smoke makes things work. When the smoke gets out, it stops! |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
How many 'hardware timers' on that 28 pin model ? |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
What the world needs is PWMPAL in the MicroMite ! https://solarbotics.com/download.php?file=722 |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9488 |
Clickable link HERE EDIT: You could always get one of those and hook it to the uM... ![]() Smoke makes things work. When the smoke gets out, it stops! |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
I've got one . The only weakness (for my purpose) is the range of frequency ... If it had an 'external clk' rather than it's xtal that'd do it ! |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6220 |
The price is a bit steep compared to the micromite. I might be interested if it had 32 bit counters instead of 16 bit. Jim VK7JH MMedit |
||||
hitsware Guru ![]() Joined: 23/11/2012 Location: United StatesPosts: 535 |
> if it had 32 bit counters instead of 16 bit right.....then enough range from xtal how many hardware counters in the MaxiMite chip ? |
||||
Page 1 of 2 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |