Skip to content

Object oriented ADC interface for firestorm #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hsysuper
Copy link
Contributor

@hsysuper hsysuper commented Mar 9, 2015

Finished the ADC interface for firestorm.

Example usage:

storm.n.adcife_init()
a0 = storm.n.adcife_new(storm.io.A0, storm.io.LOW, storm.n.adcife_ADC_REFGND, storm.n.adcife_12BIT)
v = a0:sample()
print(v)

The value "v" returned is the raw value as documented in 38.6.12 (p1000) in the datasheet. The user is responsible to take the conversion from this value to engineering values by solving the equation such as:

2047 + (Vin/Vref)*2047 = v
--> Vin = (v - 2047) / 2047 * Vref

However as eLua shell does not support floating points, I suggest multiply by 1000 before any division to get a mV engineering unit or other meaningful units.

[BEARCAST]

@hsysuper
Copy link
Contributor Author

hsysuper commented Mar 9, 2015

A sample application is made to demonstrate the functionalities. Since we won't have the show-n-tell, please feel free to try it out on your own firestorems:

https://github.com/UCB-IoET/personal-jackhe/tree/weekly/week5/adcApp

This is a client-server app in which a server act as an ADC probe that can sense voltages using its 5ADC channels; a client act as an ADC client that can request the remote probe to sense a voltage and send it back.

This app requires 2 firestorms: client runs adcclient.lua, server runs adcprobe.lua. After discovering the server, client can call measure(serial_no, adc_ch_num) to measure voltages over the air (serial_no is the serial number of the server firestorm, adc_ch_num is the the ADC channel number ranges from 0 to 5). The value returned would be in the unit of mV with 3.3V reference.

@hsysuper hsysuper changed the title Finsihed the analog read library so that it returns an object with metat... Object oriented ADC interface for firestorm Mar 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant