Setting different command modes for each channel (HDC2450)

8 years 11 months ago #29526414 by Anonymous
I recently purchased a HDC2450 controller. Now I've the following question: is it possible to select different command modes for each channel? on one channel I have an analog joystick to control a motor and on the other channel I want to run a 17 script. so each command mode gets constant information.
When I select analog to priority 1 and RS232 as priority 2, only the joystick works and when RS232 is priority 1 and analog is priority 2 only the script works.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526415 by Roboteq
You cannot set the priority differently for each channel.
The best way to resolve your problem is to do it inside the script. That is: script runs all the time and sends commands in priority. You should have the Analog command in lowest priority or even disabled. Then, have the script read the analog command with the getvalue(_CIA ... This reads the command from the joystick, and then in your script you decide if you want to apply it depending on the situation.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526416 by Anonymous
I have a script that works.
But now the following question, is it possible to run the script only with the controller so without usb or serial connection?
I have Script autostart enabled and with the laptop I sometimes get the message in the picture, this happens when I go from e.g. configuration tab to scripting tab when script autostart is enabled and I just have downloaded the script to the device. But when the program works and I disconnect the laptop and reset the controller nothing happens.
Is there a solution to those problems?

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526417 by Roboteq
There is no way to have the script not start when connected to serial or usb.
What are you trying to do?
We have never seen the error you are reporting. Is your script outputting data to the serial port? That could interfere with other communication that takes place when the utility is running.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526418 by Anonymous
here is the code I have in my script:
___________________________________________________

wait(5000)

top: ' Label marking the beginning of the script.

sideshift_links = GetValue(_DI,7) 'Lees digitaal input 7 in
sideshift_rechts = GetValue(_DI,8) 'Lees digitaal input 8 in
analog = GetValue(_CIA, 1) 'Read analog input

if sideshift_links = 1 And sideshift_rechts = 0
Setcommand(_GO, 2, 500) ' Set Motor 2 command level at 500
elseif sideshift_links = 0 And sideshift_rechts = 1
SetCommand(_GO, 2, -500) ' Set Motor 2 command level at -500
else
SetCommand(_GO, 2, 0) ' Set Motor 2 command level at 0
end if

SetCommand(_GO, 1, analog) ' Set Motor 2 command level at 0

wait(100)
' Repeat the script from the start
goto top
_____________________________________________________
so this code gets auto started
motor 1 gets controlled with an analog joystick and motor 2 must have an constand speed when a pushbutton is pressed
I only get the error if script autostart: enabled and then download the code to the controller and than go to another tab without resetting the controller first.
I don't see any problems within this code or that it is outputting data to the serial port.
and does the script gets auto started and executed in the controller when there is no laptop or other device connected trough serial or usb?

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526419 by Roboteq
We tried your script modified to also flash a LED connected on Dout 1.
It works here with the controller unconnected to a PC.

Which version of the firmware do you have?

Modified script is below:

wait(5000)

top: ' Label marking the beginning of the script.

sideshift_links = GetValue(_DI,7) 'Lees digitaal input 7 in
sideshift_rechts = GetValue(_DI,8) 'Lees digitaal input 8 in

analog = GetValue(_CIA, 1) 'Read analog input

if sideshift_links = 1 And sideshift_rechts = 0
Setcommand(_GO, 2, 500) ' Set Motor 2 command level at 500

elseif sideshift_links = 0 And sideshift_rechts = 1
SetCommand(_GO, 2, -500) ' Set Motor 2 command level at -500

else
SetCommand(_GO, 2, 0) ' Set Motor 2 command level at 0

end if

SetCommand(_GO, 1, analog) ' Set Motor 2 command level at 0

wait(100)
setcommand(_D1, 1)
wait(100)
setcommand(_D0, 1)
' Repeat the script from the start
goto top

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526420 by Anonymous
I have firmware v12 - 081411 (latest from the site) I have downloaded it with usb
I tested the script and the led blinks, so the script runs with no computer but the commands for the motor doesn't work.
I've also just heard that when the controller was delivered to the dealer it was a single channel but the dealer made it a two channel controller. maybe that is why it doesn't work and that the commands are interfering with each other

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526421 by Roboteq
If the controller is reported by the PC utility as a dual channel, then the conversion is OK.

The only thing that may need to be done, if not done already, is to reset the configuration to defaults.

We'll check the motor part.

In the meantime, replace the _CIA command with _AI to read the raw analog instead. The raw analog will be a value from around 0 to 5000, representing the real voltage at the input. Then do the conversion you need to create a valid motor command range of -1000 to +1000.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #29526422 by Anonymous
The controller is reported as dual channel in roborun.

the _AI command works!
so with the laptop connected the two motors run as they should be.

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.106 seconds