PWM Help

BlindByHand

New Member
I am building a project for class. I need to control 7 motor units and 7 servo units. i was planning on using PWM to control the speed and position of the motors and servo respectively.

I just wanted to know how many picaxe chips i will need to be able to use 14 individual PWM commands. I would like to control all of the motors and servos individually from each other. i feel like i will need 14+ picaxe chips to do that. any help would be much appreciated.
 

erco

Senior Member
Big project! A single 20M2 can drive p to 8 servos on port B only. Not sure if you could simultaneously get PWM or HPWM out of the same chip. It's a longshot but a single 20M2 might drive 7 servos plus four HWPM channels (port C and pin B.4/HPWM D).

I'll let someone else verify just how many PWM/HWPM channels one chip can drive before timing conflicts arise.

Here's my six-servo robot arm using one 20M2:

 

BlindByHand

New Member
Thank you for the reply.

from my research i have found there are 4 PWM channels on the 20M2 chip.

there are 2 possible scenarios i can think of,

1 the chip can support 4 PWM channels at once, the duty cycle can vary but the period will be the same due to the share timer. all motors or servos can be speed/position controlled based on the shared clock. but there wont be any way to have servos and motors be controlled from a single chip.

2 the chip can support 4 PWM channels with shared period and duty cycle. any motors or servos will have the same speed or position.

This is what i have found, and im pretty confused by the actual verbage in the command manual.

I will have to get my hands on some chips and get started experimenting.
 

techElder

Well-known member
BlindByHand, you haven't exactly described your project, but likely some combination of PICAXE products will satisfy your needs.

Consider designing a system of PICAXEs where certain operations are offloaded to a single PICAXE with communication amoungst the PICAXEs via an I2C network.

You should try to keep the SERVO systems isolated in this way, at least, because the SERVO commands can monopolize a program.

Tell us in more detail about what you want to accomplish.
 

BlindByHand

New Member
Texasclodhopper, you are absolutely correct i have given basically 0 info on the project. Below is a link to a video by a physics teacher, he created a "string shooter" which uses 2 DC motors spinning in opposite directions which accelerates a loop of string through two wheels. This causes the string to display some interesting properties, like behaving like a rigid body.

https://www.youtube.com/watch?v=rffAjZPmkuU&t=156s

My project will involve creating 4 units. each unit will be 1 string shooter. (2 motors to accelerate string) (1 servo to control launch angle of the string) the 4 units will be lined up so that two units are facing to the left, and two facing the right. (from a front POV). The PWM pins on the 20M2 chip will control the velocity of the string shooters by controlling the motors. [I am using two MOSFET's for each unit, 1 for each motor, each unit will be driven from one PWM pin.] The SERVO's will be mounted in such a way that the string shooters will be able to rotate ~120 degrees. Basically functions like the manually operated angle control from the video.

I am technically building 2 of these projects. the first will be for me to use in 1 and 2 below, the second one will be used for #3 below

The project will have 3 purposes.

1- My capstone MECHATRONICS project, I am in a mechatronics certification program at my local CC (Community College) and this is my last semester. The project needs to leverage a microcontroller and PICAXE chips are the department standard.
2- The program (Sierra College Mechatronics) is working with a local makerspace (HackerLab) and a sponsor (CitiBank) to hold a contest within the Mechatronics department for students in the mech 90 (capstone class). In order for a project to entered into the contest it must serve a humanitarian goal. My project will meet this goal in the following manner. Using a conductive ink pen, and the touch pins of one 20M2 chip i plan on developing a easy to replicate control board (photo paper, with traces drawn with a "Circuit Scribe" pen.) that i will take to school children. I will have them create their own control boards and using their "First Circuit" they will get to play with the string shooter. The humanitarian goal of the project is to put electronics into kids hands and getting them interested in learning/playing with electronics. I remember from when i was in grade school the things that made the biggest impact on my learning were the ones i could physically see, and touch.
3- I want to create a youtube channel partially inspired by the "Queen Of Shitty Robots" Simone Giertz. This channel will be the first phase of my plan to start my own business as a creative consultant. I will be sending one of the projects to TESTED a youtube channel created by Adam Savage from mythbusters. I would like to join the tested team and if TESTED finds my project amusing to play with we can set some goals of where they would like me to be as a channel before I was able to join their team.

Below is a link to Simone Giertz's youtube channel. She makes some pretty funny projects worth a watch if you have some free time.

https://www.youtube.com/channel/UC3KEoMzNz8eYnwBC34RaKCQ

If there is anything else i can explain about my project and/or goals please feel free to ask. Thanks for the input the both of you,I am fairly positive i will be able to complete all three goals of my project using 3 20M2 chips per project.
 

stan74

Senior Member
If you lower the clock speed less than 1MHz you could get pwm mark/space to give pulses between 750 us to 2500us but 1% changes is coarse not like pulse out if you're using servos. The 28x2 has separate pwm on b.0 and b.5 and pwm on c.1 and c.2 that run at the same frequency and mark/space.
 

stan74

Senior Member
I like your thinking bbh. True, the memorable moments in school were the most vivid. Cool you like to spread science in an inspirational way. An interesting post.
As usual "eric" you continually impress me with your real examples. I always thought your name was erco. My real name's 74 :)
 

premelec

Senior Member
@BlindByHand - you mention using 2 MOSFETs for two motors - looking at the string shoot demo it would seem you could run the two motors in series, or parallel, with appropriate polarity for rotation as they drive each other... That means ONE MOSFET + PWM would control the two - identical - motors; also a PICAXE 14M2 has 4 PWMOUT pins.

If you don't want to use servos you can use a motor acting against a spring to control angle... not clear what your power source will be and how that fits into the project...
 
Last edited:

stan74

Senior Member
BBH,is this about teaching "electronic/electrical engineering" or introducing programming? Both noble subjects that are connected but maybe an analogue speed control like a light dimmer that kids are familiar with(No,they're not but a dial idea). Please don't get me wrong but it's a faster slower knob for all intents and purposes for kids and the physics would be more fascinating than the control method. Again respect but it took me ages as an adult to realise what pwm was about. When they get older they might study string theory...or take up oragami.
 

hippy

Technical Support
Staff member
Below is a link to a video by a physics teacher, he created a "string shooter" which uses 2 DC motors spinning in opposite directions which accelerates a loop of string through two wheels.
Does that actually use two motors or use one motor with a free-running wheel being friction driven by the other ?

It can be difficult to get two motors running at precisely the same speed.
 

premelec

Senior Member
Bigger? More Mass?

In my mind I can see large variac controlled motors and spliced 9mm climbing rope demo being impressive... ;-0 Or perhaps a bicycle chain loop - .... or regular metal chain... wherever there's mass there are possibilities...
 

stan74

Senior Member
Does that actually use two motors or use one motor with a free-running wheel being friction driven by the other ?

It can be difficult to get two motors running at precisely the same speed.
Now you mention the mechanics the point is getting clearer. You must admit the effect is impressive..depending on how easily one's impressed. As a youngster, I wouldn't care less cos it looked nice and think string is cool...serious..The question is it the effect or the cause which is what to do with pwm..er, if you follow. And I took a year break in the 80's teaching. They didn't learn much..but it was entertaining.
 

premelec

Senior Member
@hippy - the two motors [if you use 2...] don't need to be sync'd as they are mechanically coupled... ;-0
 

stan74

Senior Member
it was rq3. But it won't inspire anyone cos everything's been done before by someone else so stay in bed and invent a way of doing that better but someone's done that to. :(
 

stan74

Senior Member
In my mind I can see large variac controlled motors and spliced 9mm climbing rope demo being impressive... ;-0 Or perhaps a bicycle chain loop - .... or regular metal chain... wherever there's mass there are possibilities...
ie A chain saw. That would be long lasting memories. If street entertainers used these ropey things in the uk they would be in the sun and banned like everything else in the uk. They only do the boil water in a can,wait,put the lid on,immerse in water and watch atmospheric pressure in a tv ad. Isn't that true uk members? And the cocoa can with a hole in the lid and a hole at the bottom,filled with coal gas (it is natural gas but not from beneath the north sea) igniting the top hole and as the gas burnt,air was sucked in from the bottom until the mixture exploded and the lid popped off. I don't suppose they play with calcium carbide much in schools today either. My kids are grown up but apparently they don't remember anything that stands out, so practical was changed to paper.
Actually,what's the point of teaching what is already learnt,why not teach what is not known and that would be quicker and give students an incentive. Astronomers find new earths every day.
off topic...finding new earths isn't banned in the uk yet.
 

BlindByHand

New Member
Thanks for the replies everyone!
Stan74- the goal is to create something fun play to with. the reason I was thinking of using a conductive ink pen and photo paper is to give the kids a chance to build their first circuits. One that they can keep and take home with them.

Hippy- I am no physicist but you might be right. It could work with just one motor, but i have already purchased the extra motors. also the speed of the motors should not cause to much problem, as long as they are running within a few % of each other.

Premelec- I was going to use one pin to drive the gate of 2 MOSFETS and use each MOSFET to control each motor. I chose to do it this way because using just 1 would require a more expensive MOSTFET due to the higher start up current.

My powersource https://www.amazon.com/gp/product/B01ID3KI34/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1
110 - 220 V IN 12V 5A 120W OUT.

Motor's https://www.radioshack.com/products/radioshack-super-speed-9-18vdc-hobby-motor
9-18V super speed motor

Servo Power Supply https://www.amazon.com/gp/product/B00CNXLDCQ/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1

Servo specs. 4.8 - 6 Volts. .18Sec per 60degree turn. roughly 150mA
 

techElder

Well-known member
BlindByHand, considering hardware when you select your "wheels", perhaps the driving surface should be slightly concave on at least one of the wheels.

Also, please try different gauges of "fluorescent" fishing line especially fly-fishing line. That would make a neat picture.
 

stan74

Senior Member
"Hippy- I am no physicist but you might be right. It could work with just one motor, but i have already purchased the extra motors. also the speed of the motors should not cause to much problem, as long as they are running within a few % of each other."
If they are the same motors just wire one the other way round..if they are side by side and dc. Control both at the same time.
 

hippy

Technical Support
Staff member
It could work with just one motor, but i have already purchased the extra motors.
There's no necessity though to use both and if it does save on a PWM channel it may make things easier and cheaper.

also the speed of the motors should not cause to much problem, as long as they are running within a few % of each other.
I am not a physicist either so I have no idea how much of a problem it world be. It would probably be an interesting experiment to try.

If not precisely matched each motor will be fighting the other, putting strain on the wheels and/or what passes through them.

I vaguely recall using two slightly different speed rollers is one way to roll out steel cylinders. If that's correct that means there is stretch being applied but with string perhaps not a major problem. At worst it might mean the unit doesn't shoot straight.
 
Top