PCB 1.3 und Raspberry

Hi Paddy
Like i tell you in my last post you don't need PCB.
Simply by software send a command to the PI to shutdown before the Undervoltage Pin4 cut the power on the PCB1.3
And all work like a charm.

I also use a PI zero (150mA cons ) and you can power it directly from 5VP on the PCB
if i have time i make a video with the PI3 B+ and the PI Zero so you can easily understand.
By.
 
Hi Bernard,

your solution works good for undervoltage or other situations where arduino controls the shutdown. But it will not work if you cut power externally by using main switch (I'm not talking about emergency switch) sitting between battery and PCB.

I need to find a solution for the main switch issue.

One thing makes me curious. I want to set up a connection between 3,3V from PCB to one GPIO Pin. What happens with PI during boot? After turning on PCB, it will provide 3,3V to GPIO pin. But this pin might be in a undefined state (set as input/output with or without pullup resistors). This will be only true for a few seconds on boot but does anyone know if this makes trouble?

One solution could be to use one of the unused GPIO Pins of Arduino as power_good signal. After boot up Arduino, it will power up the PI by MOSFET. With a few seconds delay, Arduino can toogle a power_good pin for the PI
 
Hi Paddy.
For the main switch simply use a protected switch like into plane.

Here the video :
JP8 in Autom mode and batterry setting correctly set.
Look at the board led

Power OFF with arduremote and without Raspberry PI.
Power ON with P20 BUTTON https://youtu.be/Tfvl9W_OYDk
With a Raspberry PI 3 (need a DC/DC) converter https://youtu.be/TjGgyjZVc3Q
With a PI ZERO (very easy to connect) https://youtu.be/XeSyF6kDqZo
So no particular issue except that to flash the DUE you need to put JP8 to ON.

By.
 
Thank you so much Bernard sharing your videos.

It is much easier to use a safe switch than to crate a PCB like I wanted to do. So I'm looking for such a switch right now. Maybe I print some protection for mine.

I still have a few questions:

- You use a common USB cable to connect PI and Arduino because they wil not power each other? Or did you cut 5v line?
- How do you send command to PI. Is it just a command via serial communication or is it something else (pin headers)?
- you changed Azurit code so it sends a coman and wait a few seconds before power off?
- why do you need to set JP8 to on? This means mower can'T disconnect when battery runs empty.
 
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.

you changed Azurit code

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::processPI(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.
 
Hi Bernard,

your videos and explanations are great. They help me a lot and I'm sure others too.

I'm sorry but I still have one questions. Last evening, I tried to run my PI from a battery. So I attached one LM2596 DC/DC converter and set it to 5V. After connecting to PI, nothing happens. Only ethernet ports blinks. When I attach a cable, LED turns off. This makes me curious and I thought I might have blown my PI. So I tried it with common AC/DC adapter and it works great.

So I tried again with battery and noticed, that the voltage drops down from 5V to 4,7v after attaching the PI. But even when I trim it back to 5V, PI will not start. I think the output of my LM2596 modules are not good (I tried three of them).
Also a 100uf capacitor did not help.

Which DC/DC converter do you use for powering PI 3? Does anyone know which one gives a stable output voltage with at least 3A?
 
Thanks again Bernard,

I was able to get it running by trimming my LM2596 modules after attaching the PI. When PI is off, output voltage of converter raises up to 6V. I think this is not safe for the pi, so I will give the modules you proposed a try.
 
Hi.
I think also it's better to use a more power DC/DC.
I read in Marotronics that the LM2596 is only 2A so certainly not enought for the PI.
By.
 
Oben