Page 1 of 1

serial command analog input

Posted: Fri Apr 24, 2020 12:36 am
by fausto.tromba
I would like to use the ADC in the MCP236. That signal will be not used to control the motor driver, but simply like a normal ADC. So instead to implement in my circuit an ADC, I thought to use the internal ADC of the motor driver.
I set in the configuration setting:
[ing]

[/img]
Mode Setting: Position
Min 0
Max 32612
both control motors are unchecked.

When the pin 13 is connected to 5 V I can read by Studio, about 23000 instead of 32612.( Why?)
How can I read by Uart the values? I'm using Python library.

Thanks in advance

Fausto

Re: serial command analog input

Posted: Fri Apr 24, 2020 9:59 am
by Basicmicro Support
ADC pins are 0 to 5.9v on the MCP. 5.9V. I am assuming you left the Min Center And Max Input setting set to 0 2048 and 4095? In this case a 0v signal will be -2047 and a 5v signal will be 1422 approximately.(eg ((5/5.9) * 4095) - 2048)

You also should not change the Command Settings. Those effect the COMMAND variable and are used when the Control Motor 1/2 check boxes are set.

Also, dont confuse the Command Settings "Position" mode with the Position variable. The position variable will show the raw input after it is mapped to the Min/Center/Max Range settings in Input Settings.

Re: serial command analog input

Posted: Sat Apr 25, 2020 1:00 pm
by fausto.tromba
Hi thank you for your feedback.
I m using MSP236 with Raspberry and your Python library.
How can i read the adc value by UART?
Tkx

Re: serial command analog input

Posted: Mon Apr 27, 2020 8:52 am
by Basicmicro Support
The usualy way would be to write a MCL script that will talk with your RPi application. What all do you need the MCP to do?

The only way to read the analog value with Packet Serial is to use the ReadSignals command which reads all values for all signals in a single command. This is rather slow(because it reads all signals data at once) and is not included the Python library so you would need to implement it.

The MCL script method is the recommended way.

Re: serial command analog input

Posted: Mon Apr 27, 2020 11:30 am
by fausto.tromba
Sorry but in the user manual I didn't find any description about ReadSingnals in the Packet Serial. what is the command number?
Can I have more details about it so I can implement it in the library? if you write directly the code witch i should write in the library we could avoid some ping pong messages

Re: serial command analog input

Posted: Wed Apr 29, 2020 7:50 am
by Basicmicro Support
Its under the packet serial section, Get Signal Values. Basically you send the address and command, it returns a byte to indicate the number of signals and then you read 4 word values per signal(pos,percent,instant speed and avr speed). First set of values is for DIN1, second for DIN2 etc...