I plan to make a wireless dc speed controller which will allow you to set the required rpm and then read the actual rpm on a remote.
The server is a uno connected to the dc motor via an esc (https://www.motiondynamics.com.au/12v-48v-dc-speed-control-single-direction-25a-pcb-model.html) reads the rpm of the motor via a Slot Type IR Optocoupler Speed Sensor Module LM393 and then adjusts the pwm out to the esc until it achieves the required rpm from the client.
The client consists of a uno with a dfrobot lcd button shield.
The server transmits the actual rpm to the client.
The client transmits the required rpm and the start/stop status to the server.
The radios are nrf24L01, low power versions.
This will be used to control an implement from the cab of a tractor.
The idea is the operator can set the required rpm from the cab of the tractor, hit start, and the server will then make adjustments to the esc to maintain the required rpm under variable conditions. If the required rpm is unable to be maintained, a piezo buzzer will sound a warning to the operator that there may be a fault, ie a jam or mechanical failure.
Are the radios likely to operate effectively in that type of environment?
I am a noob and have been reading Planning and Implementing an Arduino Program by Robin2 and have started some sketches but I am going to need a hand to get this thing working.
Is there anyone willing to comment on what I am trying to do and perhaps mentor me through this?Sketches are as follows.
Server
#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio driver
RH_NRF24 driver;
// RH_NRF24 driver(8, 7); // For RFM73 on Anarduino Mini
// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, SERVER_ADDRESS);
void setup() {
Serial.begin(9600);
if (!manager.init())
Serial.println("init failed");
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
}
void loop() {
listenForClient();
getRequiredRpm();
getStartStop();
switchOnOff();//Set relay open or closed to activate/deactivate esc.
readRpm();//Read optosensor and adjust for Rpm
adjustEsc();//Adjust Rpm to achieve required Rpm
sendRpmtoClient();
}
void listenForClient(){
}
void getRequiredRpm(){
}
void getStartStop(){
}
void switchOnOff(){
}
void readRpm(){
}
void adjustEsc(){
}
void sendRpmtoClient(){
}
Client
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
int read_LCD_buttons() { // read the buttons
adc_key_in = analogRead(0); // read the value from the sensor
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
return btnNONE; // when all others fail, return this.
#include <RHReliableDatagram.h>
#include <RH_NRF24.h>
#include <SPI.h>
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2
// Singleton instance of the radio driver
RH_NRF24 driver;
// RH_NRF24 driver(8, 7); // For RFM73 on Anarduino Mini
// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);
void setup() {
lcd.begin(16, 2);
lcd.setCursor(3, 0);
lcd.print("Lava Valley");
lcd.setCursor(5, 1);
lcd.print("Produce");
delay(3000);
lcd.clear();
lcd.print("Seedr Controller");
lcd.setCursor(1, 1);
lcd.print("by Chris Dalby");
delay(5000);
lcd.clear();
lcd.print("Set RPM");
Serial.begin(9600);
if (!manager.init())
Serial.println("init failed");
// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
}
void loop() {
listenForServer();
displayRpm();
readButtons();
adjRequiredRpm();
displayRequiredRpm();
setStartStop();
sendDatatoServer();//Send RequiredRpm & Start/Stop to Server.
}
void listenForServer(){
}
void displayRpm(){
}
void readButtons(){
}
void adjRequiredRpm(){
}
void displayRequiredRpm(){
}
void setStartStop(){
}
void sendDatatoServer(){
}