I have loaded the LIFA base to Arduino and when I power up the Arduino and DC motors are connected to power, they run immediately.
However, when i connect LabView via serial interface, they stop running...and I could control them.
How can I modify the code / where to look? / so the DC motors do not run when Arduino is on its own - no connection to LabView or until connected to LabView?
Hardware is DFRduino 1.0 (Nano but still it works even when loaded as Uno).
.... I do not expect it to run without the PC connected, but in steps:
1/ load the LIFA base to Arduino
2/ put the wireless module on Arduino
3/ switch on the Arduino ----at that moment the DC motor runs, instead of being still and waiting for the command
4/ initiate the connection (wireless or USB, does not matter) to Ar. ----DC still runs
5/ when the connection between Ard. and PC (labview) has been established -----DC stops...and waits for the command
The thing is that I only want to eliminate DC to run (robot drives by itself) before I establish the link.
All the rest is fine.
But, I am going to try with LINX, maybe that will change something.
3/ switch on the Arduino ----at that moment the DC motor runs, instead of being still and waiting for the command
OK. I see the problem. When the Arduino boots up, pin states and modes are set. Pins default to INPUT and LOW.
If something in the code changes the pin state, or mode, that can start a motor that you don't want started.
So, it appears that something in the Arduino code is setting the mode or state of a pin in a way that you don't want. Starting the Labview application and running some program changes the mode or state of the pins being used.
Without seeing the Arduino code and the Labview program, I can't offer a suggestion as to what needs to be changed in the Arduino program.
Yes, that is the problem.
The software loaded into Arduino is regular LIFA base - no change in it.....and I know the state of the pin is somewhere but since I am new to programming I do not know exactly where to start looking. I can see there are parts for DS and servo motors but what variable is carrying state for the pins 4,5,6,7?
there is AFmotor.cpp and something:
// enable both H bridges
pinMode(11, OUTPUT);
pinMode(3, OUTPUT);
digitalWrite(11, HIGH);
digitalWrite(3, HIGH);
// use PWM for microstepping support
initPWM1(MOTOR12_64KHZ);
initPWM2(MOTOR12_64KHZ);
setPWM1(255);
setPWM2(255);
} else if (steppernum == 2) {
latch_state &= ~_BV(MOTOR3_A) & ~_BV(MOTOR3_B) &
~_BV(MOTOR4_A) & ~_BV(MOTOR4_B); // all motor pins to 0
MC.latch_tx();
// enable both H bridges
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
............but I have changed that HIGH to LOW and it did not change anything.