logo elektroda
logo elektroda
X
logo elektroda

Arduino Pro Mini 16MHz: PS3 Analog Joystick, XY-FST 433MHz Transmitter & Tower Pro SG90 Servo

GaladMad 4368 10
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 15549177
    GaladMad
    Level 8  
    Hello everyone,
    recently I started to be interested in the Arduino platform. So I decided to implement a remote control car project of my idea. So I built a remote control and a car at the beginning on contact plates, both are based on the Arduino Pro Mini 16 MHz. They include:

    Remote:
    - analog joystick module ps3 5V (two potentiometers and a button),
    - regular button,
    - XY-FST 433 MHz radio transmitter

    Car:
    - led diodes,
    - Tower Pro SG90 servo 9 grams,
    - DC 5V motor with gear,
    - L293D H bridge for DC motor control,
    - buzzer,
    - radio receiver (sold with the transmitter),

    After uploading the programs to the remote control and the car, everything works, but not quite as expected. The problem is that there are large delays in operation in the car's system, i.e. when I tilt the joystick on the remote control (e.g. to the left maximum) responsible for turning, the servo in the car does movement, but not smooth, but stepwise (the servo turns by required 90 °, but by doing it in the following way: turn e.g. by 15 ° -> stop -> turn by 15 ° etc. up to 90 °) during such movement, the LED notifying about receiving the radio signal flashes with a lower frequency. Similarly, the motor, instead of making a continuous rotary motion, performs a stepwise motion in accordance with the LED blinking frequency. If, on the other hand, I do not press anything on the remote control, the diode flashes with greater frequency.

    Pilot code (emitter):
    Code: C / C++
    Log in, to see the code


    Car code (receiver):
    Code: C / C++
    Log in, to see the code


    PWM is fixed so far. I had an idea to solve the problem so that when the first signal was received, the values responsible for the control were saved, the program would continue to use them, but every few executions of the void loop so that their values were updated. Maybe that would help with car tagging, I just don't know how I could do it. Perhaps it is the fault of the poor quality of the transmitter and receiver, if someone has already encountered such a problem, please help. I would like to add that the values obtained from the signal are correct.
    Do you have a problem with Arduino? Ask question. Visit our forum Arduino.
  • ADVERTISEMENT
  • #2 15549585
    Zdzicho
    Level 25  
    Skip the transmitter and receiver, connect both arduino modules with two wires and you will see where the fault lies.
  • ADVERTISEMENT
  • #3 15549638
    andrzej55
    Level 37  
    Try disabling these service panels after the series in the main loop, because this is probably why the processor gets out of breath. Personally, I would make such transmissions with an interval of 0.5 - 1s.
  • ADVERTISEMENT
  • #4 15549831
    GaladMad
    Level 8  
    Thank you for the quick reply.

    Is the arduino connection with two wires, bypassing the radio module, about serial transmission (TX from RX and RX from TX) or something else?

    After removing the service panel, there is practically no difference. I noticed, however, that disconnecting the servo causes the car to run smoothly (i.e. the lights are on - the LEDs do not blink or blink but very quickly, which gives the impression of continuous lighting) but only until the joystick is moved in the axis responsible for the forward or backward movement of the engine, when again starts lagging everything, stops when you release the joystick.
  • #5 15625428
    domin122
    Level 16  
    Somewhere there is a ReadHead library or something - it's supposed to be faster and better in terms of the implemented protocol. And as for the blinking diode, check the masses.
  • #6 15661165
    GaladMad
    Level 8  
    If I have some time, I will work on other libraries. So far I have handled it a bit differently. In the signal reading loop, I created conditional functions that change the values of parameters controlling such activities as turning, driving direction, turning on the lights and the horn. I have thrown the functions controlling these activities outside the loop reading the signal. Now it works so that as long as the values read from the signal do not change, the void loop executes conditional functions using the last value read. I also completely removed the service panel. All controls no longer lag.

    Car CODE:
    Code: C / C++
    Log in, to see the code
  • ADVERTISEMENT
  • #8 15661741
    domin122
    Level 16  
    I guess you're on the right track. I've noticed that the more you send at once, the worse it gets. I would suggest also using the conditions in the transmitter. Let's say, for example, you send driving and directions, and the lights and horn and others separately, i.e. the control is sent, for example, 123, and the horn as, for example, the letter 'W' so that it does not get mixed up in the reading. Why send horn and light data for free when you don't use them at the moment. Let the transmitter send all the time what has a higher priority for you, and what is less should only send it when it is needed. At this stage, is it supposed to change to wifi? It is at the halfway point. And it is also supposed to generate additional costs. RC uses a time-based protocol. And in RF you are not interested in it anymore. After that, take a look at the code on Arduino and ESP.
  • #9 15662449
    Juni[]r
    Level 16  
    After all, you can make ESP on ard without lua. Anyway, just my suggestion. I don't cut myself in anymore.
  • Helpful post
    #10 15675242
    domin122
    Level 16  
    I did a few tests - the static before the signal read loop are going crazy, placed in the loop as well. Removing static helped. Do you have no-read stop at all?
    else {// if it doesn't read the signal then turn off the engine
    digitalWrite (pwm, LOW);
    }
    For me it doesn't work at all, neither on static nor without.
    The library I wrote about earlier. I haven't tested it yet.
    http://randomnerdtutorials.com/rf-433mhz-transmitter-receiver-module-with-arduino/
  • #11 15798183
    GaladMad
    Level 8  
    The last code I sent worked correctly, I gave up the line:

    "else {// if it doesn't read the signal then turn off the engine
    digitalWrite (pwm, LOW);
    } "

    by it and by placing the functions controlling all activities in the loop reading the signal, the whole system was lagging. It worked in such a way that the control signal was sent with a certain time interval, and if the receiver just read the signal, it gave values to all constants, if not, it did nothing, therefore the whole system was lagging. Placing the functions controlling all activities outside the reading loop made it possible to bypass it so that the constants that control the system still have some value, while when the receiver reads the signal, this value is updated. Thanks to this, everything is already running smoothly, i.e. you can turn the engine forward and turn at the same time, and turn the lights on or off during the maneuver. Of course you are right that sending all information from the transmitter is not the optimal solution, but sending everything at once is easier, besides in the receiver, if the control value does not change in relation to its value from the previous moment, the program in the receiver does not do anything with it do.

    Thanks for dropping off the library, it will definitely come in handy ;)

    If nobody has anything else to add, I will close the topic soon.

Topic summary

The discussion revolves around a remote control car project utilizing the Arduino Pro Mini 16 MHz, featuring a PS3 analog joystick, XY-FST 433 MHz transmitter, and Tower Pro SG90 servo. The user experiences significant delays in the car's response to joystick inputs, leading to stepwise rather than smooth servo movements. Suggestions include bypassing the radio module for direct Arduino communication to identify faults, optimizing the main loop by reducing service panel interference, and implementing conditional functions to manage control signals more efficiently. The user reports improvements after restructuring the code to separate control functions from the signal reading loop, allowing for smoother operation of the car's movements and controls.
Summary generated by the language model.
ADVERTISEMENT