I'm googleing mega328p pwm to control a hobby servo.
I can set up 1 pin to control 1 servo-50Hz, change pulse width.
Save me time looking, is it possible to pwm 4 pins at same frequency but different pulse width?
ie control 4 servos.
At the moment I use a 50hz interupt and pulse out servo value.
I guess pulseout stops the program for the pulse and four 2.25 ms pulses every 20ms means rest of program runs at half speed.
I saw a robot https://www.amazon.com/dp/B06ZZH8LZS that uses 4 servos . It uses a 10 channel pwm, i2c board. It's £30 from maker with discount code. https://www.sunfounder.com/diy-4-dof-robot-kit.html
There's plans so I could my own..I know someone with a cnc laser. Wouldn't save much money and adapting code to gcb.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks. I can do 1 channel even though I got to think. I downloaded avrcalc to help.
I wondered about pics..PIC16f1572 and probably easier with gcb than avr.
I could buy a 10 channel pwm chip with i2c for a few pound..mega board bit ott for robot but thinking of getting one anyway.
Servos need a pulse every 20 ms or so.
How about setting 50Hz pwm for pin A at 1ms mark.
Use 200Hz interrupt.
Use a counter 1 to 4, if 4 reset to 1.
1st interrupt switch the pwm to pin B at different mark.
next interrupt switch pwm to pin C.
next nterrupt switch pwm to pin D
then reset back to pin A.
so each servo gets refreshed 50Hz and changing pwm faster than pulse out..
or am I missing something?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No reason why that wouldn't work, depends on what you are doing. If this is for bot motor control then I would tend to set the 50Hz interrupt then update all channels at once. Over time you could find the bot bot pulling to one side in a straight line?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Setting up a new device is interesting.
Someone else said on this forum "arduino includes hide everything, it's cut and paste"
Do I want to use a device or know everything about it?
Do I have to be a mechanic to drive a car?
What's the B in Basic stand for ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm googleing mega328p pwm to control a hobby servo.
I can set up 1 pin to control 1 servo-50Hz, change pulse width.
Save me time looking, is it possible to pwm 4 pins at same frequency but different pulse width?
ie control 4 servos.
At the moment I use a 50hz interupt and pulse out servo value.
I guess pulseout stops the program for the pulse and four 2.25 ms pulses every 20ms means rest of program runs at half speed.
I saw a robot https://www.amazon.com/dp/B06ZZH8LZS that uses 4 servos . It uses a 10 channel pwm, i2c board. It's £30 from maker with discount code. https://www.sunfounder.com/diy-4-dof-robot-kit.html
There's plans so I could my own..I know someone with a cnc laser. Wouldn't save much money and adapting code to gcb.
Google GCB forum, and maybe you would have found this? https://sourceforge.net/p/gcbasic/discussion/projects%26guides/thread/66153766/#ae47
Need more channels? then get a Mega Board and have a whole potful of timers to play with.
Thanks. I can do 1 channel even though I got to think. I downloaded avrcalc to help.
I wondered about pics..PIC16f1572 and probably easier with gcb than avr.
I could buy a 10 channel pwm chip with i2c for a few pound..mega board bit ott for robot but thinking of getting one anyway.
Servos need a pulse every 20 ms or so.
How about setting 50Hz pwm for pin A at 1ms mark.
Use 200Hz interrupt.
Use a counter 1 to 4, if 4 reset to 1.
1st interrupt switch the pwm to pin B at different mark.
next interrupt switch pwm to pin C.
next nterrupt switch pwm to pin D
then reset back to pin A.
so each servo gets refreshed 50Hz and changing pwm faster than pulse out..
or am I missing something?
No reason why that wouldn't work, depends on what you are doing. If this is for bot motor control then I would tend to set the 50Hz interrupt then update all channels at once. Over time you could find the bot bot pulling to one side in a straight line?
timer1 can't be 4 pins.
new pics with clc..??
sent for this https://www.ebay.co.uk/itm/PCA9685-16-Channel-12-bit-PWM-Servo-motor-Driver-I2C-Module-For-Servo-Arduino-UK-/262922123992
next week delivery rather than https://www.ebay.co.uk/itm/PCA9685-16-Channel-12-bit-PWM-Servo-motor-Driver-I2C-Module-For-Arduino-Robot-UK-/201712256656
patience is £3
looks interesting
I have used the NXP PCAxxxx for driving leds before. They can work good, it still takes some work to set them up though, just like anything else.
Setting up a new device is interesting.
Someone else said on this forum "arduino includes hide everything, it's cut and paste"
Do I want to use a device or know everything about it?
Do I have to be a mechanic to drive a car?
What's the B in Basic stand for ?
Understood, I am 1600 mi. from my gear for the next few weeks anyways. So no help on a library for now.
I probably have the old PCAxxxx code sample, so I could look at that if you need help there when the time comes.