Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Arduino Communication with Roborio (http://www.chiefdelphi.com/forums/showthread.php?t=154640)

darklink2458 02-02-2017 21:41

Arduino Communication with Roborio
 
We have an arduino that runs the lights on our teams robot. We were wondering if there is a way to have the arduino react to commands made from the driver station. Thanks for any help you can provide.

elijah1111 02-02-2017 21:47

Re: Arduino Communication with Roborio
 
what do you mean by the driver station commands? what you could do you could use a pwm line or dio from the roborio to the ardouino and read it there

skidad68 02-02-2017 21:48

Re: Arduino Communication with Roborio
 
You can have the Driver Station talk to the roboRIO, and then have the roboRIO talk to the Arduino using the serial port or I2C.

elijah1111 02-02-2017 21:51

Re: Arduino Communication with Roborio
 
Quote:

Originally Posted by skidad68 (Post 1639716)
You can have the Driver Station talk to the roboRIO, and then have the roboRIO talk to the Arduino using the serial port or I2C.

How complicated of lighting are we talking here? Would a simple PWM line or DIO not suffice. Just have the roborio output a PWM wave to the arduino to read then you could have your various lighting settings based on the PWM signals.

elijah1111 02-02-2017 22:13

Re: Arduino Communication with Roborio
 
I would do something like this on arduino side, you could also have multiple pwm values for diffrent lights if you wanted it to.
Code:

float PWMsignal;//the signal from the roborio
void setup() {
  // put your setup code here, to run once:

PWMsignal=0;//intilizes signal

Serial.begin(9600);//syncs up serial output
}

void loop() {
  // put your main code here, to run repeatedly:
  PWMsignal=analogRead(3);//reads the pwm value for pin 3

  if(PWMsignal=42){//if its whatever pwm value you want turn pin 4 on
    digitalWrite(4,HIGH);
  }
  else{
    digitalWrite(4,LOW);
  }
Serial.println(PWMsignal);//outputs value to serial port
}


euhlmann 03-02-2017 07:37

Re: Arduino Communication with Roborio
 
Quote:

Originally Posted by elijah1111 (Post 1639724)
Code:

float PWMsignal;
// ...
if(PWMsignal=42)
// ...


:ahh:

RyanN 03-02-2017 11:03

Re: Arduino Communication with Roborio
 
Quote:

Originally Posted by euhlmann (Post 1639779)
:ahh:

:ahh: indeed

Code:

int PWMsignal;
// ...
if (PWMsignal == 42)
// ...

I would say that using that method would be highly susceptible to problems. You're relying on some undefined capacitance on the analog pin of the Arduino, cabling, and RoboRIO's PWM pins. You can use I2C, SPI, UART, or UDP/TCP if you get an Ethernet shield.

Another dead simple way would be to use some DIO as outputs. You can have 2^n modes where n is the number of outputs you use.

From Easy to Hard (my opinion of course):
DIO, UART, TCP/UDP, I2C


All times are GMT -5. The time now is 07:10.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi