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

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 663

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.

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

robofreak

Rookie

Joined: Wed Aug 22, 2012 2:06 amPosts: 6

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

JohnWatson

Site Admin

Joined: Thu May 24, 2012 12:15 pmPosts: 663

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.

Who is online

Users browsing this forum: No registered users and 2 guests

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