BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Fri Jul 20, 2018 1:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: HPWM period in micro seconds
PostPosted: Sat Jun 20, 2015 3:34 am 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
I am working in replacing a worn out motor to a Garrard GTX35 turntable with a stepper motor using the nano 28 command HPWM to control the motor speed to 33.3333.The problem is that I need to send a pulse every 1800ms to the motor driver so the stepper motor run at 33.3333 rpm. I have been unable to do it because the period it is in micro seconds and I can not lower it. Does any one knows any idea or a work around that allow to lower the period other than micro seconds. Right now every thing it is working OKAY with the exemption of the pulse width frequency. Thank you in advance.


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Fri Jun 26, 2015 1:10 am 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
HI

Can you confirm what you are trying to do exactly ?,

Every 1800ms you need to output a pulse so that's every 1.8 seconds ?, how long is the pulse to be ?, does the pulse go to some kind of stepper motor controller unit that uses the pulse width to set the speed it runs at ?,

Can you post a circuit diagram and the current working software that's working OK ?,

Many thanks
Dave

BasicMicroUK


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Fri Jun 26, 2015 5:11 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi Dave.

I am using the easy driver module to drive the stepper motor. I need to send a frequency of 662 cps or a pulse of 400usec with a period of 1500usec. The reason of the 662 cps it is because the ratio of the platen diameter and the motor spindle pulley diameter. Right now I am using as a test an LM555 adjusted to 662 cycles per seconds. The timing to get 33.33333 RPM it is a pulse of 400usec with a duration of 1500usec. After the test with the LM5555 switched to the NANO28X and I cannot program the HPWM to get a 800usec pulse with a duration of 1600usec. Maybe I am not setting right the HPWM. The maximum period for the HPWM it is 16383. Checking the output with the scope using 16383 for the period and 5000 for the duty the reading for the period is 800usec with a pulse of 200usec. I think this is the maximum you can output for the HPWM. The pulse it is not critical. I hoped the above explanation clear what I am trying to accomplishing. Right now using the LM555 I can control the speed of the stepper motor to run the platen at 33.3333. The purpose of the project it is to control the platen speed constant. Using the LM555 the speed it is no constant and need to make some adjustment to maintained the speed that it is why the used of the Nano28X. To calculate the RPM I used an infrared sensor with a metal strip glued to the platen. I calculate the RPM by reading the time it takes for one revolution.

Command used for the HPMW

test_pwm
HPWM pwm_chnl_1, 16383 , 5000
return


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Thu Jul 02, 2015 11:57 am 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
HI

Well running at a 20MHZ clock frequency of the Nano-X range you can not get close to the 662Hz frequency you require BUT if you use a standard Nano running at an 8MHZ clock then the closest you can get would be a frequency of 661.38Hz, would that be OK ?,

Is it the frequency or the pulse width that is critical for your application ?,

What else is the Nano doing in the main loop ?,

Many thanks
Dave
BasicMicroUK


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Thu Jul 02, 2015 11:24 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
I tried to use the command PR2 = 0xFF to change the clock frequency to 1.22kz and the TMR2 = 0x3 that would change the prescaler and the frequency period but it didn't work. I think when you executed the PWM override the two commands. Also I will use the micro to display the RPM and to control the ON/OFF of the turntable and some other features. I may go to the NANO 18 if I can not do it using the NANO28X.


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Fri Jul 03, 2015 10:42 am 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
HI Again

On the Easy Driver module what step mode are you in ?, I am thinking that by running at half, quarter micro stepping modes for example the required frequency would be higher, looking at the data for the IC used on the Easy Driver its only the pulse frequency that's critical and not the width of the pulse so it may be easy to set something up using a timer interrupt to send the pulse to the stepper driver,

I have ordered an Easy Driver PCB so I can do some tests on the minimum pulse width it will trigger on and then see if the interrupt method can be used on the Nano-28X IC,

Many thanks

Dave
BasicMicroUK


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Fri Jul 03, 2015 3:38 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
I am using the full step. I didn't used the other step options because I do not know if going half step there it is not enough torque to start the platen. The platen it is heavy. I can try it and see if there are not problems starting the platen. Anyway it is a good suggestion. I think you should add to the command HPMW to allow to change the clock timer prescaler 1, 4, 16 that will give the PWM Frequency of 1.22 kHz 4.88 kHz 19.53 kHz 78.12 kHz 156.3 kHz 208.3 kHz. This will allow to divide the clock by 1, 4 or 16 or allow to output the frequency directly.
I didn't post the schematic since it is simple circuit. Just read the marked pulse from the platen as an input , calculate the rpm and sent the pulses to the stepper motor. It is a simple principle. The most important it is sent the stepper pulses every 1800ms. The width of the pulses it not critical.

Thank in advance for the help.


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Fri Jul 03, 2015 10:42 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
I ran a tested setting easy driver half step and the platen ran Okay by changing the period from 16383 to 12000. Lowering the period less than 11000 the platen does not started. Right now I can control the RPM at 33.3333 setting the period at 15040. Now I need to write the program to control the RPM of the platen at a constant speed.


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Sat Jul 04, 2015 11:49 am 
Offline
Site Admin
User avatar

Joined: Fri Apr 12, 2013 8:38 pm
Posts: 87
Location: Nottingham, England, UK
HI

That's great, I am pleased it worked OK for you with the half step method,

Maybe you can increase the stepper motor current a little to assist the sluggish start up if needed or have a motor start routine where for the first few seconds the PWM is set to get the system up and running and then you switch to the closed loop speed control mode for the fine control,

Many Thanks

Dave
BasicMicroUK


Top
 Profile  
 
 Post subject: Re: HPWM period in micro seconds
PostPosted: Sat Jul 04, 2015 5:06 pm 
Offline
Master

Joined: Wed Oct 19, 2011 2:28 am
Posts: 123
Hi,
What I did was what you suggested. Start the platen a full step and then switched to half step. Once it is running the motor keep the speed at 33.3333 rpm. I played some records and the sound it is great. Also by going to half speed the whining of the stepper motor when out. Now it is running quietly.

I would like to thank you very much for the help. I almost scrap the project but was very satisfies to keep working until found a simple solution to solve it.

Again thank you very much.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO