Go Down

Topic: nrf24l01 + old aritronics + L298N need a little help. (Read 589 times) previous topic - next topic

Robin2

This does not inspire confidence
Code: [Select]
    Serial.print("    LeftMSpeedF =");
      Serial.println(RightMSpeed);



When I saw this
Quote
the left motor does not twitch UNTIL LeftMSpeed hits 255 in either forward or reverse direction. Then it kicks in and goes at full speed in whatever direction is required of it.
my first thought was that you have the driver pins wired incorrectly.


Another wild thought ...
You are using pin 10 for the PWM signal for the left motor and pin 10 is the Slave Select pin for SPI communication. You don't have to use it for SPI and, as required, you do have it set as OUTPUT. I don't know if its role in connection with SPI would affect its ability to do PWM but it might be worth trying a different PWM pin to see what happens.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

jonawadl

quote/This does not inspire confidence
Code: [Select]

    Serial.print("    LeftMSpeedF =");
      Serial.println(RightMSpeed);
/quote

Ya, that's a bit of a goof, but does not matter to the end result because its on the right motor, which is working as it should.

I have experimented with the pins too. I switched to 9 for pwm for a bit to test. It made no difference but it did introduce some chatter to the servo for some reason so I switched it back.

Next step, I'm going to switch out the big 12V motors for something that might be easier to turn. It's a long shot because one seems to work fine and I have swapped left to right already.



Robin2

quote/This does not inspire confidence
Code: [Select]

    Serial.print("    LeftMSpeedF =");
      Serial.println(RightMSpeed);
/quote

Ya, that's a bit of a goof, but does not matter to the end result because its on the right motor, which is working as it should.
My concern is that you have been looking at data for working right motor thinking that it is the data for the left motor. Maybe if you get it to print LeftMSpeed you will see that the value is not working the way you think.

If the motors are working with the wired code then they should work with the wireless code. Don't go wasting your time and mental energy on pointless experiments.


If you reorganize the code as I suggested you can use the exact same code (apart from one function) for both wired and wireless. That way you greatly reduce the area for exploration if the wireless version does not work.

You have not said, but I have been assuming that you tested your wired code on the exact same hardware as the wireless code (apart from the wireless hardware, of course).


...R
Two or three hours spent thinking and reading documentation solves most programming problems.

jonawadl

#33
Mar 23, 2019, 02:44 am Last Edit: Mar 23, 2019, 02:46 am by jonawadl
Ok I went back to the proverbial drawing board. I tore everything down and went back to a wired system to check my understanding that everything was working to begin with.

I discovered that I had a basic on-off forward reverse switch with one stick and a perfect speed controller forward and reverse on the other stick.

This would make somebody believe there's a problem with the code. But that's not the case.
 

I have one of these units.



When I take the six input pins and directly mirror them so that the right stick controls the left motor, everything reverses itself. Now the sticks have reversed roles. They do the opposite of what they did before. To me that indicates a hardware problem.

Here's the sticker though. I have three L298N units. All three behave exactly the same. Should I believe they are all faulty?

jonawadl

After further review, I think there's something else going on. When I mirror all connections, the opposite joystick works as expected but the opposite motor works as expected too.

So both channels in the L298N work, it just depends on the input.

I can't think it through here. I thought I had it. I'll do some thinking to see if I can solve what's going on.

jonawadl

#35
Mar 23, 2019, 03:36 am Last Edit: Mar 23, 2019, 03:39 am by jonawadl
and one more update for tonight.  I went off the rails a bit and hooked up two L298N one for left motor one for right motor. Same results. It's always PWM pin 10 that has proportional control.

jonawadl

Ok, I lied about not posting again. today. After the last experiment I realized it had to lie in the code. So I went and did more reading and looking for more examples of working code.

I came across this site https://dronebotworkshop.com/dc-motors-l298n-h-bridge/. That was a fun read. I got both motors working as they should with wired connections. I'll play with the wireless from here and post my results back.

Sorry for leading people on a goose chase with code that wasn't working in the first place. Im sure I tired it and realized I had forward and reverse on both sticks then checked only one for proportional and it happened to be the right one.


Robin2

Sorry but none of what you are saying about changing connections and reversed behaviour is understandable without a clear wiring diagram (NOT Fritzing, please) and the program code for each option.

In my experience changing too many things in quick succession is not helpful for debugging. One needs to have a hypothesis about what is the cause of the problem followed by a change (in hardware or software) that tests that hypothesis.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up