Помогите написать скетч для машинки на радиоуправлении.
- Войдите на сайт для отправки комментариев
Пнд, 06/04/2020 - 09:33
Здравствуйте, хочу сделать RC машинку на ардуино С бессколлекторным электродвигателем. Читать скетчи могу, но сам вообще не умею писать. Проэктов с коллекторным куча, а вот с бессколлекторным не нашел. Управление НЕ по блютуз или wifi, просто на Nrf24l01.
Делайте.
Учитесь.
Ваш будет первым.
ну в интернете очень много готовых схем и скетчов. вот напрмер
https://create.arduino.cc/projecthub/muhammad-aqib/high-speed-arduino-rc...
на Nrf24l01 еще больше инфы
ну даже не знаю ставить такой двиг на машинку )
это можно добиться скорости до 100 -130 кмч если не больше :)
смотря как и что строить будете. конечно устойчивость скорее всего никакая будет. все от конструкции зависит.
пишите свои идеи. какая конструкция будет. помогу собрать. точно такую же прошивку делаю но чуток сложнее
На большую скорость и рассчитываю
Про конструкцию еще сильно не думал, но точно задний привод
Днище из дерева, потому что легко изготовить и дёшево.
Знаю что не надёжно, за то дёшево и довольно малый вес.
Вот как раз сегодня начну думать над конструкцией.
/* DIY RC Receiver - Servos and Brushless motors control by Dejan, www.HowToMechatronics.com Library: TMRh20/RF24, https://github.com/tmrh20/RF24/ */ #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> #include <Servo.h> RF24 radio(3, 2); // nRF24L01 (CE, CSN) const byte address[6] = "00001"; unsigned long lastReceiveTime = 0; unsigned long currentTime = 0; Servo esc; // create servo object to control the ESC Servo servo1; Servo servo2; int escValue, servo1Value, servo2Value; // Max size of this struct is 32 bytes - NRF24L01 buffer limit struct Data_Package { byte j1PotX; byte j1PotY; byte j1Button; byte j2PotX; byte j2PotY; byte j2Button; byte pot1; byte pot2; byte tSwitch1; byte tSwitch2; byte button1; byte button2; byte button3; byte button4; }; Data_Package data; //Create a variable with the above structure void setup() { Serial.begin(9600); radio.begin(); radio.openReadingPipe(0, address); radio.setAutoAck(false); radio.setDataRate(RF24_250KBPS); radio.setPALevel(RF24_PA_LOW); radio.startListening(); // Set the module as receiver resetData(); esc.attach(10); // Arduino digital pin D10 - CH9 on PCB board servo1.attach(4); // D4 - CH1 servo2.attach(5); // D5 - CH2 } void loop() { // Check whether we keep receving data, or we have a connection between the two modules currentTime = millis(); if ( currentTime - lastReceiveTime > 1000 ) { // If current time is more then 1 second since we have recived the last data, that means we have lost connection resetData(); // If connection is lost, reset the data. It prevents unwanted behavior, for example if a drone jas a throttle up, if we lose connection it can keep flying away if we dont reset the function } // Check whether there is data to be received if (radio.available()) { radio.read(&data, sizeof(Data_Package)); // Read the whole data and store it into the 'data' structure lastReceiveTime = millis(); // At this moment we have received the data } // Controlling servos servo1Value = map(data.j2PotX, 0, 255, 0, 180); // Map the receiving value form 0 to 255 to 0 to 180(degrees), values used for controlling servos servo2Value = map(data.j2PotY, 0, 255, 0, 180); servo1.write(servo1Value); servo2.write(servo2Value); // Controlling brushless motor with ESC escValue = map(data.j1PotY, 127, 255, 1000, 2000); // Map the receiving value form 127 to 255 to 1000 to 2000, values used for controlling ESCs esc.writeMicroseconds(escValue); // Send the PWM control singal to the ESC } void resetData() { // Reset the values when there is no radio connection - Set initial default values data.j1PotX = 127; data.j1PotY = 127; data.j2PotX = 127; data.j2PotY = 127; data.j1Button = 1; data.j2Button = 1; data.pot1 = 1; data.pot2 = 1; data.tSwitch1 = 1; data.tSwitch2 = 1; data.button1 = 1; data.button2 = 1; data.button3 = 1; data.button4 = 1; }пример приемника может выглядеть так. выше код
почитай пока вот это что бы стало меньше вопросов
https://howtomechatronics.com/projects/diy-arduino-rc-receiver/
возможно понравится этот проэкт
https://howtomechatronics.com/projects/diy-arduino-based-rc-hovercraft/
https://howtomechatronics.com/projects/diy-arduino-rc-receiver/
https://howtomechatronics.com/projects/diy-arduino-rc-transmitter/
надо это изучить и понять как подключается и работает двигатель я так понял еще 1 серво будет как руль?