Now before you tear me a new one, I want to disclose, I am reading and still learning arduino. I have visual basic and some C programming experience, but limited. I’m also not pawning off my work of reading and learning myself here, so please don’t throw me under the bus.
What I’m really asking for here is guidance in regards to 1) if this project will work as described, with you all knowing the limits of an arduino uno more than me from real life experience, 2) known pitfalls I could avoid -i.e. “that won’t work because…”, and 3) if you could point me in my reading/studies to a thread or threads that might already address this. (I’m still actively drudging through sections I think might be related, finding some useful things here and there, and going off on a LOT of tangents)
Background: I am learning and reading about H bridges, motor shields, and arduino programming. I am not a student rushing some project, I am simply wanting to get into robotics and teach my 4 and 6 year old sons some of this along the way.
The concept of programming in general is not foreign to me, I am simply still learning arduino and how programming can meet the physical work of mechanized action. Thanks for your help and patience.
The thought with problems: (feasible, or not?)
Basic blink style sketch, but you run 2 motors through each pulse instead of LEDs (4 total motors, and yes I understand I’ll likely need to use a motor shield or relay). Have 2 pulses. The shared motors are opposing each other both in front and side position, i.e. front left motor pairs in sequence with rear right motor.
This would produce a “walking” robot if even straight legs were attached.
Great, now what?
Well, now you can add directional guidance. This would mean decreasing the stride (motor running time) on the side to which you want to turn. By extending less on this side, the opposing side will have a longer stride and make more progress/distance, thereby “steering” towards the side with the shorter stride.
The problem is, that you can’t sequence the way mentioned above because both the left and right sides would have shorter strides, cancelling each other out.
So you’d have to have all working independently of eachother, but the aruino can only run one process at a time. So instead of wiring all independently, you just have an interupt to the power source on one side. This would cut power on the side you want to turn towards, allowing only the opposing side movement. This would solve the problem and could be accomplished with your directional controller. When turned towards the right for example, all power to the right motors would cease until the directional controller changed direction (straight, or to the opposing direction).
This may not be the smoothest transition, imagine being mid-stride and you lose power, it may cause the thing to fall towards the side you are turning. So you might be able to accomplish this with a voltage control. Instead of cutting power, you bring it down to a lower voltage. Then there’s an if statement, that if voltage drops from X, then the motor is stopped in the vertical position - straight legged.
I don’t know if this would be possible with a single arduino.
The next issue is variable speed control, not a big deal, you can get a speed knob and tie it in to a variable that represents speed and so adjusts the “blink” delay to a shorter time to speed up the process, or a longer time to decrease the speed… with a loop function that checks the knob setting every so often.
This would give you speed control, with the knob at zero position being “off” or no speed.
As for what I’ve done, besides in my head, I’ve literally just used LEDs as fake motors to see if the speed and parallel action would work, which it has. And yes, this is a modification to the blink sketch.
[ code ]
Parallel Alternating Motors
Turns on a motor circuit on for one period of time, then off for the same time period while turning on the alternate motor relay, repeatedly.
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int motor1 = 13;
int motor2 = 12;
// the setup routine runs once when you press reset:
// initialize the digital pin as an output.
// the loop routine runs over and over again forever:
digitalWrite(motor2, LOW); // turn the 1st motor on and 2nd motor off(HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(motor2, HIGH); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
[ code ]
Obviously this doesn’t include much and would simply have the thing walking for days. Before I went any further, I wanted input so I could steer myself in the right direction before tackling the syntax of what I’m hoping to accomplish.
The goal for now is to get a small scale model toy version, then once the bugs are worked out to build something with pvc legs and affix a seat and control knobs to it to have the kids play around on after I’ve tested it for safety.
Why? It’d be fun.