Hi ,i have a rc-car with a magnetic steering (+volts right, -volts left) which i'm controling it with a L298P Motorshield.The only Problem is that the steering kinda vibrates an won't really move.So my question is, how can i make the motor shield working with this electromagnet ?Or could PLL-mode on this shield (for three-phase-motors) control it ? Before i do anything maybe dangerous for the circuits, i want to ask someone with more experience

What is the code you're using to control the motorshield? You don't want to PWM the motor driver for an electromagnet steering mechanism. Either drive it full on one direction, full on the other direction, or full off. If you PWM the signal, that will cause the electromagnet to vibrate.

I send a control-string of 8 characters, [2] is left and [3] is right, i'm always using the max. 255 for steering in one direction and LOW/HIGH. If [2] or [3] is not 'x', i set it to 0 volt.

It currently uses PWM and i'm not sure what the PLL-mode is...When i listen to the sound that it makes, i get the feeling that the controller is giving out a stuttering (_-_-) voltage, like on->off->on... in very fast.Maybe the magnet could work better without that fast on-off...

Edit:I have set the Motor2 to PLL, but i don't rellay know a thing about it.Heres what i have figured out so far:M2 LOW -> Does nothing on any E2-Value ?M2 HIGH -> enables Speed Control (in only one direction ?)

With M2=HIGH and E2=0, i can turn left just fine. But what about Right ?

E1 and M1 are the FWD/Backward setting pins, Reverse is HIGH, forward is LOW. E2 and M2 are the PWM pins, you should be able to use these as digitalWrite pins and not use pwm at all. This will send Full Left with lets say E2 at HIGH and E1 at LOW. Center is E2 = LOW. Full right would be E1 at HIGH E2 at HIGH

"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent di

Back to the PWM-mode, it dosent work perfect, but at least i have left and right...

But there was something else i've noticed, the controller seems to get the signal, but then its sending out a low power (~40%) which then switches to the set power value after ~0,5 seconds delay.shouldn't it give out the full power instantly ?

Your control for receiving input and controlling the car is a bit... wonky (no offense intended) and overcomplicated. I can't see anything that will obviously cause the problems you are seeing, but a more simplified control scheme will not only make it easier to debug, but make it less likely that there will be a problem to debug from the start.

To that end, don't even bother checking for invalid characters. Since you only perform actions based on valid characters, there's little benefit being gained by doing so.

Only set IO points when you receive a command packet. There's no benefit to repeatedly setting IO points to the same values over and over and over. Again, there shouldn't technically be anything wrong with doing so, but it can make diagnosing and debugging problems more of a headache than it already is.

You can also easily reduce your drive control down to a single byte and your steering control down to a single byte.

Steering control byte would just be a three state control.val1 = straight aheadval2 = leftval3 = right

Drive control would only be slightly more complicated. Using a signed char variable, you have a range of -127 to 127. if the val is less than 0, set you direction to reverse, otherwise set it to forward. Take the absolute value of the variable, multiply it by 2 (then add 1 if you absolutely want the max speed possible, but the reality is the difference between 254 and 255 is likely negligible), and that's your speed.

Good to hear. I never even noticed those lines from your original code, but that is clearly what was causing your problems.

As another side note, you may want to look at the difference between & and && as well as | and ||. For what you're doing in your comparisons, the bitwise & and | operators are still accomplishing your goal, but you really should be using the boolean && and || operators in comparisons.