Machinekit- READ ADC VALUE ONLY!!! (NO TEMPERATURE!!!)

120 views
Skip to first unread message

Matus Kamensky

unread,
Apr 20, 2016, 9:15:53 AM4/20/16
to BeagleBoard
Hi. I use machinekit  for controlling my CNC mill and i need read ADC pin (AIN0) to set speed of my motor (0-4000rpm). I need convert voltage (0-1,8V) to pwmgen.parameter(0-4000). Can You help me? Thanks.

Charles Steinkuehler

unread,
Apr 20, 2016, 10:06:17 AM4/20/16
to beagl...@googlegroups.com
Start with the BBB temperature code:

https://github.com/machinekit/machinekit/blob/master/src/hal/user_comps/hal_temp_bbb.py

...use "none" for the thermistor and use the .raw HAL pin in your HAL
file. If you want, you can delete the code that converts ADC values
to a resistance and then a temperature value, or add some appropriate
scaling so you can directly connect the .raw output pin to your pwmgen
input.

--
Charles Steinkuehler
cha...@steinkuehler.net

Matus Kamensky

unread,
Apr 20, 2016, 10:18:49 AM4/20/16
to beagl...@googlegroups.com
Thanks for your answer. But i don´t know, how this structure or command write. I work with AVR microprocessor, no with linux. Can you send me some examples  of command, which I solve my problem? . I need only number with range 0-4000 from 0-1,8V (AIN0). I use machinekit,debian 3.8. and beagle bone black (own cape).Thanks


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/zTS1a2GxEYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/57178CCD.9030907%40steinkuehler.net.
For more options, visit https://groups.google.com/d/optout.

Charles Steinkuehler

unread,
Apr 20, 2016, 10:47:14 AM4/20/16
to beagl...@googlegroups.com
You need Machinekit HAL file knowledge, not Linux (or AVR).

You load the ADC code with a line like this:

https://github.com/machinekit/machinekit/blob/master/configs/ARM/BeagleBone/CRAMPS/CRAMPS.hal#L35

...except you will probably want to use "none" for the thermistor
(which is epcos_B57560G1104 in the example above). Adjust the
channel(s) (04: and 05: in the example above) to select the ADC input
pin you wish to use.

Then you need to connect the ADC reading to your PWM driver with a HAL
signal like so:

https://github.com/machinekit/machinekit/blob/master/configs/ARM/BeagleBone/CRAMPS/CRAMPS.hal#L365-L366

...but you should use the .raw signal (ie: Therm.ch-04.raw) instead of
the value to get a value between 0-4095.

Since this is specifically a Machinekit question, you should probably
be asking on the Machinekit Google group:

https://groups.google.com/forum/#!forum/machinekit

On 4/20/2016 9:18 AM, Matus Kamensky wrote:
> Thanks for your answer. But i don´t know, how this structure or command write. I
> work with AVR microprocessor, no with linux. Can you send me some examples of
> command, which I solve my problem? . I need only number with range 0-4000 from
> 0-1,8V (AIN0). I use machinekit,debian 3.8. and beagle bone black (own cape).Thanks
>
> 2016-04-20 16:06 GMT+02:00 Charles Steinkuehler <cha...@steinkuehler.net
> <mailto:cha...@steinkuehler.net>>:

Matus Kamensky

unread,
Apr 20, 2016, 12:05:36 PM4/20/16
to beagl...@googlegroups.com
I create connection between machinekit (i create variable PWM.meas => this variable will use to PWM) and script hal_temp_bbb. Now i need edit a script. Can you help me with this problem? 
This is the script:

https://github.com/machinekit/machinekit/blob/master/src/hal/user_comps/hal_temp_bbb.py

 I tried edit this sections:
def adc2r_cramps(pin):
V_adc = pin.rawValue
# V_T = 0.0 # Voltage across the thermistor
# R_PU = 2000.0 #Pull-up resistence
# I_PU = 0.0 # Current flowing through the pull-up resistor
# R_T = 0.0 # Resistance of the thermistor
# V_T = V_adc
# No dividing by zero or negative voltages despite what the ADC says!
# Clip to a small positive value
# I_PU = max((1.8 - V_T ) / R_PU, 0.000001)
# R_T = V_T / I_PU
return V_adc
def adc2Temp(pin):
if(args.cape_board == 'BeBoPr'):
R = adc2r_bebopr(pin)
elif (args.cape_board == 'CRAMPS'):
R = adc2r_cramps(pin)
else:
print("Invalid -b cape name: %s" % args.cape_board)
print("Valid names are: BeBoPr, CRAMPS")
sys.exit(1)
return round(R)
But without corect solution.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/zTS1a2GxEYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Matus Kamensky

unread,
Apr 27, 2016, 4:36:03 AM4/27/16
to beagl...@googlegroups.com
Hi. I have one problem with this ADC conversion. I create connections between HAL file and this ADCfile (hal_temp_bb). Everything works, but if the ADC send me value more than 1600 (0-6000), my JOG wheel stop working. I use some GPIO PINs for axis_enable(X,Y,Z) and axis_jog scale (UP,DOWM). This button not responding, while ADC_value is more than 1600. If ADC_value is less than 1600. this button works. Can you help me with this problem ?? Thanks.

P8.16 in # Manual-5 JOG_EN_X
P9.24 in # Manual-6 JOG_EN_Y
P9.25 in # Manual-8 JOG_EN_A
P9.26 in # Manual-7 JOG_EN_Z
P8.17 in # Manual-4 JOGMUX_2
P8.18 in # Manual-3 JOGMUX_1

Can you help me make this file more simple? I don´t need read resistance table(delete from this file). I need Only adc_value.

Matus Kamensky

unread,
Apr 27, 2016, 4:44:07 AM4/27/16
to beagl...@googlegroups.com
hal_temp_bbb
Reply all
Reply to author
Forward
0 new messages