OCCRA
Go to Post Kyle from team 45 said "Dude, I still have 2 years left in FIRST ahahaha.." My response to that was... "Kyle, I have till the day I die." - Arefin Bari [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-12-2017, 02:39 PM
AlkyAky AlkyAky is offline
Registered User
FRC #6429
 
Join Date: Nov 2016
Location: Turkey
Posts: 3
AlkyAky is an unknown quantity at this point
Arduino to roborio on i2c

Hello everyone i want to use pixy with arduino because of the easy library but i have an issue i use slave_sender example to send data but i dont know how to receive data with java i2c class.I am going to use readOnly() function to recieve data but the count parameter needs to fill with how many bytes to read from arduino but i dont know how many bytes. The data i want to get is 0-319.I use java iterative.Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 11-12-2017, 04:49 PM
Sjtumlin16 Sjtumlin16 is offline
Registered User
AKA: Seth Tumlin
FRC #4521 (Harrison Robotics)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Harrison, OH
Posts: 9
Sjtumlin16 is an unknown quantity at this point
Re: Arduino to roborio on i2c

Quote:
Originally Posted by AlkyAky View Post
Hello everyone i want to use pixy with arduino because of the easy library but i have an issue i use slave_sender example to send data but i dont know how to receive data with java i2c class.I am going to use readOnly() function to recieve data but the count parameter needs to fill with how many bytes to read from arduino but i dont know how many bytes. The data i want to get is 0-319.I use java iterative.Thanks!
I don't use java but I have gotten the pixy to communicate with arduino over I2C without using the pixy library. If you would like I can post the arduino code and you can use it to figure out how to do it in java with the roboRIO.
Reply With Quote
  #3   Spotlight this post!  
Unread 11-12-2017, 09:13 PM
WSiggs WSiggs is offline
Pb Programmer
FRC #4908 (Dragons)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2014
Location: Duxbury Massachusetts
Posts: 43
WSiggs is on a distinguished road
Re: Arduino to roborio on i2c

If you are sending the data yourself from the Arduino you should know how many bytes of data you are sending. What data type(s) are you sending from the Arduino, as that will show how dictate how many bytes you are sending. In the slave sender example they show that each character in a String will register as a byte for example. If you could post your code for the Arduino in this thread that would also be helpful.
Reply With Quote
  #4   Spotlight this post!  
Unread 11-13-2017, 12:09 AM
AlkyAky AlkyAky is offline
Registered User
FRC #6429
 
Join Date: Nov 2016
Location: Turkey
Posts: 3
AlkyAky is an unknown quantity at this point
Re: Arduino to roborio on i2c

Quote:
Originally Posted by WSiggs View Post
If you are sending the data yourself from the Arduino you should know how many bytes of data you are sending. What data type(s) are you sending from the Arduino, as that will show how dictate how many bytes you are sending. In the slave sender example they show that each character in a String will register as a byte for example. If you could post your code for the Arduino in this thread that would also be helpful.
I think it is short should i write 2 bytes right?and the arduino code like this
Wire.write(pixy.blocks[0].x)
Reply With Quote
  #5   Spotlight this post!  
Unread 11-13-2017, 12:10 AM
AlkyAky AlkyAky is offline
Registered User
FRC #6429
 
Join Date: Nov 2016
Location: Turkey
Posts: 3
AlkyAky is an unknown quantity at this point
Re: Arduino to roborio on i2c

Quote:
Originally Posted by Sjtumlin16 View Post
I don't use java but I have gotten the pixy to communicate with arduino over I2C without using the pixy library. If you would like I can post the arduino code and you can use it to figure out how to do it in java with the roboRIO.
That would be so great thanks
Reply With Quote
  #6   Spotlight this post!  
Unread 11-13-2017, 05:53 AM
Sjtumlin16 Sjtumlin16 is offline
Registered User
AKA: Seth Tumlin
FRC #4521 (Harrison Robotics)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Harrison, OH
Posts: 9
Sjtumlin16 is an unknown quantity at this point
Re: Arduino to roborio on i2c

Quote:
Originally Posted by AlkyAky View Post
That would be so great thanks
Code:
#include <Wire.h>       

byte c[16];
int j = 0;
int i = 0;

void setup() 
{
  pinMode(13, OUTPUT);  //Built in LED
  
  Wire.begin();         // join i2c bus (address optional for master)
  Serial.begin(9600);   // start serial for output

  delay(500);
}

void loop() 
{
  Wire.requestFrom(0x54, 16);   //Ask for 16 bytes from pixy with adress 84 (0x54 in hex)
  
  while (Wire.available())      //If there's data then start the loop
  {
    for (i=0; i<16; i++)        
    {
      c[i] = Wire.read();       //Store in an array

      if(c[i] == 85 && c[i-1] == 170)     //If we get 170 then 85 then restart because we're out of sync
      {
        i == 1;
      }
    }  
    if(c[2] == 0)               //If the checksum is 0 then we don't have any data so dont print it
    {
    }
    else
    {
      for (j=0; j<16; j++)
      {       
       if (j <= 3)              //Don't print the syncronazation bytes
       {
       }
       else
       {
        Serial.print(c[j]);
        Serial.print("\t");    //\t is "tab"
       }

       if(j == 15)
       {
        Serial.println(" ");  //Start a new line at the last byte and turn on an LED
        digitalWrite(13, HIGH);
       }
      }   
    } 
  }

  delay(250);
  digitalWrite(13, LOW);      //Turn off LED and wait because yoou won't even be able to read it if it goes too fast.
  delay(250);
}
This might be helpful for figuring out what the data means http://www.cmucam.org/projects/cmuca...erial_Protocol
Reply With Quote
  #7   Spotlight this post!  
Unread 11-13-2017, 07:53 AM
rafi's Avatar
rafi rafi is offline
Registered User
FRC #0449 (The Blair Robot Project)
Team Role: Mechanical
 
Join Date: Nov 2016
Rookie Year: 2016
Location: Maryland
Posts: 12
rafi is an unknown quantity at this point
Re: Arduino to roborio on i2c

We used i2c to send the alliance color, teleop, and auto to the rioduino for LED customization. We used the wpilibib I2C package. You can see the RoboRIO side code on on our Robot.java, with the write method starting on line 316, and our rioduino side code here, with the read method starting on line 126. If the documentation isn't to par or something doesn't make sense, just say so.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:22 PM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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