Hi Paddy.
You use a common USB cable to connect PI and
Arduino because they wil not power each other? Or did you cut 5v line?
It's common USB Cable between pi and
arduino.B)
Yes the Pi can power again the
Arduino but only if the
arduino did not receive power from main : 9V
if it's occur the PI is not powered also, for example it's your main switch.
To power the Pi ZERO it's a cable with only 5V and GND.
Into Azurit i change this But maybe it's not exactly the same in your code :
into Pfod add a "rt" command to shut down:
SendcommandMenu:
Code:
serialPort->print(F("|rk~Start Tracking"));
serialPort->print(F("|rt~Power OFF PCB"));
serialPort->print(F("|r1~User switch 1 is "));
processCommandMenu(String pfodCmd)
Code:
sendCommandMenu(true);
} else if (pfodCmd == "rt") {
robot->batSwitchOffIfIdle = 0; // to stop immediatly the PCB
sendCommandMenu(true);
} else if (pfodCmd == "r1") {
robot->userSwitch1 = !robot->userSwitch1;
robot->setUserSwitches();
sendCommandMenu(true);
So the delay before shutdown is set to 0
Into robot.cpp (need to check for your version)
Code:
if (bluetoothUse) {
rc.readSerial();
//if (rc.readSerial()) resetIdleTime();
}
You need to remove the resetidletime when use BT, readserial and everywhere in the code exept when the mower is OFF or into the Station without Timer in Use.
And into checkBattery add a simple Delay(50000) so the DUE freeze until the PI is down and the PI USB don't power the
arduino.
Code:
if (idleTimeSec != BATTERY_SW_OFF) { // battery already switched off?
idleTimeSec = idleTimeSec + 1; // add 1 second idle time because check only each 1 secondes
if (idleTimeSec > batSwitchOffIfIdle * 60) {
if (RaspberryPIUse) {
Console.println(F("PCB power OFF after 50 secondes, need to wait until PI Stop power the USB Native Port"));
MyRpi.sendCommandToPi("PowerOffPi");
delay(50000); //wait 50Sec until pi is OFF or the USB native power again the due and the undervoltage never switch OFF
}
else
{
Console.println(F("PCB power OFF immediatly"));
}
setBeeper(200, 50, 50, 200, 100 );
loadSaveErrorCounters(false); // saves error counters
loadSaveRobotStats(false); // saves robot stats
idleTimeSec = BATTERY_SW_OFF; // flag to remember that battery is switched off
Console.println(F("BATTERY switching OFF"));
setActuator(ACT_BATTERY_SW, 0); // switch off battery
How do you send command to PI.
All the command are send via USB and NMEA message.
When the PI want to shutdown it's send a PFOD command with ("rt"),so the OFF is initiate by the Due exactly like if we use the arduremote command Power OFF.
When the
Arduino want to shutdown it send this to the PI (and wait 50 secondes): MyRpi.sendCommandToPi("PowerOffPi") and the PI start shutdown immediatly.
From the PI i can simulate all the Arduremote command with a NMEA sentence type.
why do you need to set JP8 to on?
Sorry for the confusion JP8 always in Autom.
ONLY WHEN DOWNLOAD
A NEW FIRMWARE FROM THE PI YOU NEED TO PUT IT ON OR POWER THE DUE VIA PROGRAMMING PORT.
NOT sure but i think:
If JP8 in Autom:
When you download a new firmware from your PC the due kill the power on the PCB and use the programming USB power to continue to work.
When you download a new firmware from the PI the due kill the power on the PCB and the Pi is down also so it can't work.
If JP8 in ON.
The pi is always ON so no problem.
You can find the PFOD.cpp into attachments.
Look at the end for the PI command
void RemoteControl:
rocessPI(String RpiCmd, float v1, float v2, float v3) {...
and here for example for the Slider
Code:
void RemoteControl::processPIDSlider(String result, String cmd, PID &pid, double scale, float maxvalue) {
if (dataFromPi) {
pid.Kp = value1;
pid.Ki = value2;
pid.Kd = value3;
}
else {
int idx = result.indexOf('`');
String s = result.substring(idx + 1);
//Console.println(tmp);
float v = stringToFloat(s);
Hope it can help.