Wireless UART Remote with encoder device selection

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AnKn_4645196
Level 1
Level 1
First like given

I have a question I’m building a UGV and a UAV later down the road. I have the remote side and the UGV/UAV side. The remote talks to the UGV via wireless UART. On the remote I have a hall effect joystick (0-5v), 5 buttons and a encoder for device selection. Ideally I would like to use the same remote to control the UGV and UAV.

pastedImage_1.png

The wireless UART module is made by Linx: Amplified HumPRO® Series Long Range RF Transceiver Module

I know it has addressing capability but I don't want to over complicate the code.

There are 3 main questions I have.

  1. What would be the best way to take the ADC value of the joystick and send it over uart for proportional speed control? Basically I want to use the ADC value to control the PWM value on the UGV side.
  2. What would be the best way to format the uart data?  Encoder_(button statuses, ADC _X, ADC _Y) the encoder value would determine if the data is for the UGV or the UAV. UGV _(button statuses, ADC _X, ADC _Y) or UAV _(button statuses, ADC _X, ADC _Y).

One thing Im confused about is what to do with the \Joystick:SAR:Bypass\ pin. Also do I need the VDAC component for the vref?

pastedImage_0.png

Here are pictures of what I'm working on.

pastedImage_2.png

The LCD is just to show

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

ankn,

To speed-up development process I may suggest using custom rotary encoder and button switch components. The AN for QuadDecoder also includes an example of the 2x16 LCD menu control:

Quad Decoder with Button Switch component for rotary shaft encoders

ButtonSw32: button switch debouncer component

encoder_01b.png

ButtonSw_basic_1b.png

The button switches shown on the picture have quite a bit of ringing and must be debounced. The ButtonSw32 component can handle this issue. 

3. The choice of Vref for ADC depends on joystick voltage output range. Typically, internal Vref=1.024V is sufficient. Joystick accuracy is typically low (<8bit), so enabling a bypass pin \Joystick:SAR:Bypass\ for a bypass capacitor is not necessary.

2. UART gives freedom to invent own protocol. Typical approach is to assign a 1-byte prefix for each specific command, followed by a value and termination. For example, let's make 1-byte command prefix id:

J - joystick

B - button (pressed)

b - button (released)

S - start

etc.

Then a control message may look like this:

"J" + "10" + "20" + LF+CR (each one is a byte) will send joystick position (10,20).  Corresponding HEX string: "0x4A 0x0A 0x14 0x0D 0x0A"

"B" + "2" + LF+CR will send buttons pressed event (bit 2 corresponds to button 2).  Corresponding HEX string: "0x42 0x02 0x0D 0x0A"

You can find basic UART Rx demo showing decoding such commands for RGB LED control (like "R128\r\n") here:

UART string reception garbage value

/odissey1

View solution in original post

1 Reply
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

ankn,

To speed-up development process I may suggest using custom rotary encoder and button switch components. The AN for QuadDecoder also includes an example of the 2x16 LCD menu control:

Quad Decoder with Button Switch component for rotary shaft encoders

ButtonSw32: button switch debouncer component

encoder_01b.png

ButtonSw_basic_1b.png

The button switches shown on the picture have quite a bit of ringing and must be debounced. The ButtonSw32 component can handle this issue. 

3. The choice of Vref for ADC depends on joystick voltage output range. Typically, internal Vref=1.024V is sufficient. Joystick accuracy is typically low (<8bit), so enabling a bypass pin \Joystick:SAR:Bypass\ for a bypass capacitor is not necessary.

2. UART gives freedom to invent own protocol. Typical approach is to assign a 1-byte prefix for each specific command, followed by a value and termination. For example, let's make 1-byte command prefix id:

J - joystick

B - button (pressed)

b - button (released)

S - start

etc.

Then a control message may look like this:

"J" + "10" + "20" + LF+CR (each one is a byte) will send joystick position (10,20).  Corresponding HEX string: "0x4A 0x0A 0x14 0x0D 0x0A"

"B" + "2" + LF+CR will send buttons pressed event (bit 2 corresponds to button 2).  Corresponding HEX string: "0x42 0x02 0x0D 0x0A"

You can find basic UART Rx demo showing decoding such commands for RGB LED control (like "R128\r\n") here:

UART string reception garbage value

/odissey1