View unanswered posts | View active topics It is currently Sat Nov 29, 2014 4:39 am






Reply to topic  [ 5 posts ] 
How to add new Shields & Sensors? 
Author Message
Rookie

Joined: Wed Aug 22, 2012 2:06 am
Posts: 6
Post How to add new Shields & Sensors?
Hello everyone!
I liked the RobotC for Arduino very much, especially the debugger.
But I have a question: how can I add extra hardware support into the environment? For example, for shields with different pin mappings or new sensors.
'Cos I want to program a robot with Pololu Dual VNH5019 Motor Shield, and it uses 2 pins for direction and 1 for speed, for each motor (not like the DFRobot Motor Shield). So all I need is to modify a motor constructor slighly, but I cannot find sources anywhere. I eagerly wish to add support for my shield, but I don't know how!


Wed Aug 22, 2012 2:13 am
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 610
Post Re: How to add new Shields & Sensors?
Hello robofreak, and welcome to the forums!

Have you tried the Motors and Sensors setup window? It should allow you to designate which ports are used for inputs/outputs, which gives you the freedom to set up the Arduino as you see fit (as long as you use have the pins set up correctly). You can then save the setup as a template and use it whenever you want to run that particular Arduino sensor/shield.

John

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Aug 24, 2012 10:22 am
Profile
Rookie

Joined: Sat Sep 01, 2012 5:05 pm
Posts: 1
Post Re: How to add new Shields & Sensors?
I have the same issue. The problem with the Pololu shield (TB6612FNG dual motor driver chip) is that it has two inputs for direction and they each need to be in the opposite state (0,1 for forward and 1,0 for reverse). The Motor Sensor configuration only allows one discrete output for direction control. This could be solved by adding a logic gate inverter to drive one of the motor driver inputs, but is there a way to do it without additional hardware?

Thanks,
-Mike


Sat Sep 01, 2012 5:20 pm
Profile
Rookie

Joined: Wed Aug 22, 2012 2:06 am
Posts: 6
Post Re: How to add new Shields & Sensors?
Thank you John for your kind reply.

What I meant is I wanted to save my setup in a nice fashion, to select it then from the drop-down list. Well, it's just a suggestion for the new release and not so really important.

What bothers me more is that the following lines result in an error:
#pragma config(Motor, motor_3, MotorLeft, tmotorExternalHBridgeDualPWM, openLoop, IOPins, dgtl3, dgtl12)
#pragma config(Motor, motor_11, MotorRight, tmotorExternalHBridgeDualPWM, openLoop, IOPins, dgtl11, dgtl13)
This is simply my setup for Arduino Motor Shield, which really takes PWM from 3 and 11, and direction from 2 and 13.
The error on debug is following:
***Byte Code Exception***
Source: opode message <SetSourceValue> (0x12)
Exception Type: 'Motor out of range(2)'

I cannot understand this error and cannot drive my robot :(


Sat Sep 01, 2012 5:22 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 610
Post Re: How to add new Shields & Sensors?
The reason ROBOTC compiles with an error in this instance is because the Dual PWM H Bridges require both pins to have PWM capabilities; in this case, the secondary pins (2 and 13) do not. Only pins 3, 5, 6, 9, 10, and 11 have PWM capabilities on the Arudino UNO/Duemilanove/Diecimila.

You can add custom setups to the Motor and Sensors Setup 'Custom Models' drop down menu. You will need three things;

1) A ROBOTC source code file with the appropriate setup (set up the Arduino pins in Motor and Sensors Setup, apply the changes, and remove all other code except for the #pragma statments from the code and then save it as whatever you would like the model to be named).

2) An Rich Text Format (RTF) file with the text you would like displayed as a description for the model.

3) A 413x388 JPEG image that you would like displayed with the model.

Once you have those three things, make sure they are all named the same (Testbot.c, Testbot.rtf, and Testbot.jpg, respectively) and place them in ROBOTC's MotorAndSensorModels folder (under the appropriate subfolder; the MotorAndSensorModels folder is found in ROBOTC's program data folder, which is typically located in C:/Program Files (x86)/Robomatter Inc/ROBOTC Development Environment/MotorAndSensorModels). As long as the files are saved correctly they should show up in the standard models drop menu.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Tue Oct 09, 2012 4:56 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.