Go to Post Looks very well designed. Now where is the "export to reality" button in the CAD software? (I have been looking for it for weeks). - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 04-02-2012, 10:44
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Live C++ help

I'm at the school all day, but none of my programming students are expected to be here today. The school network doesn't block google docs, and it has a live chat component. So if you've got a C++ or maybe a Java (I know Java, but I don't know the WPILib specifics) question today, head to this document and ask a question:
https://docs.google.com/spreadsheet/...=en_US# gid=0

To open the chat window, click the coloured square in the top right

I'd probably be best at:
-Syntax/"why isn't this compiling" question
-How to use the camera
-How to use the gyro/accelerometer
-Some amount of cRio debugging

So, ask away! Make my day go by quicker!

You can also ask in the thread, but I may not notice it right away.

Last edited by Bongle : 04-02-2012 at 10:49.
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2012, 16:57
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Live C++ help

Alright, I'm done.

This was pretty workable though - the only problem is that google docs doesn't make a noise when a collaborator chats, so sometimes I didn't notice when I had a new message.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2012, 20:53
agartner01 agartner01 is offline
Captain + Control Sys & Design
FRC #4174
Team Role: Engineer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Hector MN
Posts: 109
agartner01 is an unknown quantity at this point
Re: Live C++ help

Hey there, I saw this thread and was wondering if you could help me get the accelerometer (and possibly the gyro) setup. The following is copied and pasted from the official FIRST forums.


I have my accelerometer plugged into the digital sidecar via the I2C bus. I try to set it up but just get compile errors. Can't understand why. Can someone help me out? Code below. Bold indicates complie errors.

Code:
ADXL345_I2C *accelerometer;
...
accelerometer = new ADXL345_I2C (1,kRange_2G);
...
std::cout<<accelerometer->GetAcceleration(Axes kAxis_X);

Last edited by agartner01 : 06-02-2012 at 20:56.
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2012, 08:04
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Live C++ help

Try the following:
Code:
ADXL345_I2C *accelerometer;
...
accelerometer = new ADXL345_I2C (1,ADXL345_I2C::kRange_2G);
...
std::cout<<accelerometer->GetAcceleration(ADXL345_I2C::kAxis_X);
__________________
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2012, 14:55
agartner01 agartner01 is offline
Captain + Control Sys & Design
FRC #4174
Team Role: Engineer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Hector MN
Posts: 109
agartner01 is an unknown quantity at this point
Re: Live C++ help

Alright, now it complies. But when I look at the console all I see is a bunch of zeros. I read in the accelerometer manual I have to apply power, but I'm unsure how to do that. (something with the PowerCtlFields)
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2012, 16:18
jpolitano jpolitano is offline
Theprogrammer18
FRC #1257 (Parallel Universe)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: New Jersey
Posts: 1
jpolitano is an unknown quantity at this point
Re: Live C++ help

Hey Does anybody know how to get a camera tracker to work? Ours just prints out random lines. The program basically makes random lines in all directions to look for different colors. If anyone wants to help me please contact me somehow.
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2012, 17:05
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Live C++ help

Quote:
Originally Posted by agartner01 View Post
Alright, now it complies. But when I look at the console all I see is a bunch of zeros. I read in the accelerometer manual I have to apply power, but I'm unsure how to do that. (something with the PowerCtlFields)
I am not sure what you meant by apply power. If you have connected the accelerometer correctly to the I2C bus, the I2C bus has power pins that supply power to the accelerometer. You don't need to have code to "apply power". The moment you turn on the Robot, the accelerometer should be powered. I would check the wiring of the accelerometer to make sure you have the +5, GND, SCL and SDA pins connected correctly and the digital side car has power and you have fixed your DB37 cable.
__________________
Reply With Quote
  #8   Spotlight this post!  
Unread 07-02-2012, 17:17
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Live C++ help

Quote:
Originally Posted by jpolitano View Post
Hey Does anybody know how to get a camera tracker to work? Ours just prints out random lines. The program basically makes random lines in all directions to look for different colors. If anyone wants to help me please contact me somehow.
Have you looked at the provided VisionSample2012 code? If you have installed the latest update (http://firstforge.wpi.edu/sf/frs/do/...2_update_for_c), you will see the vision tracking sample. We wrote our code based on that with some mminor optimization and it seems working well.
__________________
Reply With Quote
  #9   Spotlight this post!  
Unread 07-02-2012, 18:58
agartner01 agartner01 is offline
Captain + Control Sys & Design
FRC #4174
Team Role: Engineer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Hector MN
Posts: 109
agartner01 is an unknown quantity at this point
Re: Live C++ help

Quote:
Originally Posted by mikets View Post
I am not sure what you meant by apply power. If you have connected the accelerometer correctly to the I2C bus, the I2C bus has power pins that supply power to the accelerometer. You don't need to have code to "apply power". The moment you turn on the Robot, the accelerometer should be powered. I would check the wiring of the accelerometer to make sure you have the +5, GND, SCL and SDA pins connected correctly and the digital side car has power and you have fixed your DB37 cable.
I checked the connections, I'm pretty sure they're right. Other digital sidecar functions works (pwm's & relay's). I have no idea what's wrong. I'll include some pictures



Reply With Quote
  #10   Spotlight this post!  
Unread 07-02-2012, 19:00
agartner01 agartner01 is offline
Captain + Control Sys & Design
FRC #4174
Team Role: Engineer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Hector MN
Posts: 109
agartner01 is an unknown quantity at this point
Re: Live C++ help

If that dosen't work, could someone show me how to hook it up the other way (and the code accompanying it).
Reply With Quote
  #11   Spotlight this post!  
Unread 07-02-2012, 19:16
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Live C++ help

Two things:
1. It doesn't solve your problem but your picture showed that the +5 wire is black and the GND wire is red. The robot inspector will probably frown on this since this is opposite to the convention.
2. Could you change your line to the following instead? If you are not moving, the X axis will read zero. But Z will give you approx. 1 (since earth has 1G). Or you should move the accelerometer board around to see if the reading changes.
Code:
std::cout<<accelerometer->GetAcceleration(Axes kAxis_Z);
__________________
Reply With Quote
  #12   Spotlight this post!  
Unread 07-02-2012, 20:19
agartner01 agartner01 is offline
Captain + Control Sys & Design
FRC #4174
Team Role: Engineer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Hector MN
Posts: 109
agartner01 is an unknown quantity at this point
Re: Live C++ help

1. I didn't really realize the opposite wiring convention, kinda just plugged it in
2. When it was x, i turned it in all direction and it still remained 0.

All I can think right now is defective/static/faulty connectors(digital board), bad cables, etc...

Could you tell me how to hook it up the other way and see if that works? I have no idea how to do it.

Last edited by agartner01 : 07-02-2012 at 20:21.
Reply With Quote
  #13   Spotlight this post!  
Unread 07-02-2012, 21:10
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Live C++ help

If you have a voltmeter, you can check the voltage between the +5 and the GND pins on the accelerometer to make sure it indeed gets power (in case you have bad connector). If you have an oscilloscope, check the SCK line, it should give you a train of square wave. No matter what color wires you hook it up, make sure +5 is connected to +5, Gnd to Gnd, SCL to SCL and SDA to SDA. By convention, +5 should be RED and Gnd should be BLACK.
__________________

Last edited by mikets : 07-02-2012 at 21:12.
Reply With Quote
  #14   Spotlight this post!  
Unread 07-02-2012, 21:19
agartner01 agartner01 is offline
Captain + Control Sys & Design
FRC #4174
Team Role: Engineer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Hector MN
Posts: 109
agartner01 is an unknown quantity at this point
Re: Live C++ help

Alright... Thanks for all the help, I really appreciate it. I'll try it out tomorrow.
Reply With Quote
  #15   Spotlight this post!  
Unread 08-02-2012, 09:27
Bob649 Bob649 is offline
Technical Mentor
FRC #0649 (Fish)
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Saratoga HS
Posts: 7
Bob649 is an unknown quantity at this point
Re: Live C++ help

Hello,
I use the i2c pins closest to the NXT connector. I read in a post that the ones you are plugged into are a slower i2c bus, but I don't have the formal documentation on that. Try the other pins and double check that you have the order on the 2x2 cables correct to the board. It is easy to turn one around with these types of cables. When I go in tonight, I'll try my working system on the pins you are on and see if it works there too.
Regards,
Bob
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 12:42.

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