Go to Post We don't build robots because it's easy, we do it because it's hard. Maybe we can work on giving new members a warmer and gentler welcome, because it's hard ;). - Winged Globe [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 26-07-2016, 11:29
Ngang's Avatar
Ngang Ngang is offline
Registered User
FRC #2265 (Fe Maidens)
Team Role: Electrical
 
Join Date: Jan 2015
Rookie Year: 2014
Location: New York
Posts: 11
Ngang is an unknown quantity at this point
How to use C with a Raspberry Pi servo HAT?

Hi, I've been working on a project not entirely FRC related but I was hoping someone would have some advice.

It's my first time working with Raspberry Pi, but my team wants to try and use them and ROS to control a large group of robots with C, but it doesn't seem like C is really supported by that many libraries with the HAT. Are there other programming languages more viable for this? Does anyone have any experience with the HAT and C?
Reply With Quote
  #2   Spotlight this post!  
Unread 26-07-2016, 11:39
Andrew Lobos Andrew Lobos is offline
Registered User
FRC #0225 (TechFire)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Lancaster, PA
Posts: 61
Andrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the rough
Re: How to use C with a Raspberry Pi servo HAT?

I ported the Adafruit servo HAT library to C++ for a personal project a while ago. Worked great for driving a few victors on a small robot. This is the HAT I used: https://www.adafruit.com/products/2327

Here's the source: https://github.com/4ndr3w/PiBot/blob...rivers/PWM.cpp

https://github.com/4ndr3w/PiBot/blob.../drivers/PWM.h

You'll need to link it with the WiringPI library.

Also be very careful if you're driving a large robot like this - if your program crashes/exits, the servo hat will keep outputting the last PWM value it was set at.
__________________
2012-2014: 225 Driver, Programmer & Co-Captain
2012-2014: FTC 4977 Driver, Programmer, & Team Captain
2011: 225 Operator & Programmer

2013: FRC: Springside-Chestnut Hill Winner (w/341 & 1495), Midknight Mayhem Winner (w/316, 369, & 869), Battle O' Baltimore Winner (w/1640, 2914 & 339), Duel on the Delaware Finalist (w/816 & 369), Ramp Riot Winner (w/341, 304, & 4637) FTC: PA State Finalist
2014: FRC: Springside-Chestnut Hill Winner (w/316 & 1495), Greater DC Winner (w/1731 & 4464), Midknight Mayhem Winner (w/25, 1626 & 329) FTC: PA State Champion
Reply With Quote
  #3   Spotlight this post!  
Unread 26-07-2016, 11:58
Ngang's Avatar
Ngang Ngang is offline
Registered User
FRC #2265 (Fe Maidens)
Team Role: Electrical
 
Join Date: Jan 2015
Rookie Year: 2014
Location: New York
Posts: 11
Ngang is an unknown quantity at this point
Re: How to use C with a Raspberry Pi servo HAT?

Thanks!
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 23:09.

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