serial command analog input

General discussion of the MCP motion controller product line
Post Reply
fausto.tromba
Posts: 37
Joined: Wed Jul 31, 2019 7:24 am
serial command analog input

Post 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
Attachments
Unbenannt.PNG
Unbenannt.PNG (7 KiB) Viewed 14517 times
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: serial command analog input

Post 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.
fausto.tromba
Posts: 37
Joined: Wed Jul 31, 2019 7:24 am
Re: serial command analog input

Post 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
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: serial command analog input

Post 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.
fausto.tromba
Posts: 37
Joined: Wed Jul 31, 2019 7:24 am
Re: serial command analog input

Post 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
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: serial command analog input

Post 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...

Post Reply