I am using ADALM 2000 device to perform some standalone datalogging for some sensors testing. I couldn't find except one example video for this operation which is this video: https://www.youtube.com/watch?v=-QblCcu9x_o
since I am a windows user, I downloaded the example provided by Analog Devices as a txt file, then changed the name and the format of the file to "runme.sh" and uploaded this file into a flash drive and connected it through an USB OTG cable to ADALM2000 which is connected to my sensor as specified by the video. the good point is that the LED became stable which means that the .sh file is pulled successfully. however, after around 5 minutes I browsed the flash drive, but couldn't find any csv files as I expected.
the questions are:
1- what are the steps that should be followed to perform the standalone datalogging if I am a windows user.
2- what are the limitations of ADALM2000 when performing this test, for example can I perform standalone datalogging of I2C or SPI sensor?
// that is the sh script that I used :
This example measures ambiental temperature with
#an AD22100 voltage temperature sensor, using the M2K.
#It requires these connections:
#M2K Sensor
#V+ -> V+
#GND -> GND
#1+ -> V0
#uri defaults to local
#to use other backends, pass the uri as command line argument
OFFSET=1.375 #voltage offset
TEMP_CT=0.0225 #AD221OO constant
ts=600 #time between measurements in seconds
valid=true
count=1
uri="local:"
if [ $# != 0 ] && [ "$1" != "start" ] #automounter uses start as parameter
then
uri="$1"
fi
#change directory to the drive, when running on local context
if [ "$uri" = "local:" ]; then cd /media/sda1/; fi
#create output file
touch output.csv
sleep 5
#calibrate ADC
m2kcli analog-in $uri -C
#power sensor
m2kcli power-supply $uri --generate channel=0 value=5
while [ $valid ]
do
#read voltage
voltage=$(m2kcli analog-in $uri -v channel=0 raw=0 -q)
temp=$(echo "($voltage-$OFFSET)/$TEMP_CT" | bc)
#write result to output file
echo "$count. $temp °C" >> output.csv
echo "Reading one value every $ts seconds. CTRL+C to break"
sleep $ts
count=$((count+1))
done
As described in the video, does data logging work remotely ? If running it from the Windows machine ?
Also, what firmware version are you using ? This example requires firmware at least v0.28.
-Adrian
I updated the firmware to v0.31. copied the data_logger.sh file into a flash drive, then changed it's name to runme.sh
afterwards, I used an OTG cable to mount my flash drive and LED1 became stable, now after waiting for a while I retrieved my flash drive and couldn't file the csv file that was supposed to be autogenerated on the flash drive.
this means that I didn't have to write my own shell script for the basic example. and as far as I know the operating system won't be a matter since I didn't generate my own shell script to be put on external flash drive
please let me know if I am wrong.
Please open the file from the flash drive with an editor and check the line ending, whether it's Windows or Unix specific.
Thanks!
-Alexandra
thank you so much it helped a lot, for now I would like to know how difficult it is to perform a standalone datalogging for I2C, UART sensors using the same technique?
Thank You so much!
The example you posted reads the analog input and converts the voltage into temperature (here: https://github.com/analogdevicesinc/libm2k/blob/master/tools/m2kcli/examples/data_logger.sh#L37 ).
In the following directory ( https://github.com/analogdevicesinc/libm2k/tree/master/tools/m2kcli/examples ) you can find examples for I2C or UART using m2kcli. Using those, you can tweak your runme.sh script to call any of the possible m2kcli commands.
I would recommend running your script remotely in the beginning and transfer it to the flash drive only after everything works from your Windows machine.
-Alexandra
The example you posted reads the analog input and converts the voltage into temperature (here: https://github.com/analogdevicesinc/libm2k/blob/master/tools/m2kcli/examples/data_logger.sh#L37 ).
In the following directory ( https://github.com/analogdevicesinc/libm2k/tree/master/tools/m2kcli/examples ) you can find examples for I2C or UART using m2kcli. Using those, you can tweak your runme.sh script to call any of the possible m2kcli commands.
I would recommend running your script remotely in the beginning and transfer it to the flash drive only after everything works from your Windows machine.
-Alexandra
#-q is the quiet, that get results only #- channel 1 is 2+ # we use option1 for i2c sensors ts=1#time between measurements in seconds valid=true count=1 uri="local:" if [ $# != 0 ] && [ "$1" != "start" ] #automounter uses start as parameter then uri="$1" fi #change directory to the drive, when running on local context if [ "$uri" = "local:" ]; then cd /media/sda1/; fi #create output file touch output1.csv touch pressures.csv sleep 5 #calibrate ADC m2kcli analog-in $uri -C #power sensor m2kcli power-supply $uri --generate channel=0 value=5 while [ $valid ] do pressure=$(m2kcli i2c $uri -i frequency=100000 address=0x78 scl=0 sda=1 -r bytes_number=2 option=1) sleep $ts byte11=$(echo $pressure | cut -d' ' -f1) byte22=$(echo $pressure | cut -d' ' -f2) value=$(( (byte11 << 8) | byte22 )) voltage=$(m2kcli analog-in $uri -v channel=1 raw=0 -q) pressure_bar=$(echo "scale=4; $value/13106.5" | bc) echo " $count $pressure_bar; $byte11; $voltage" >> pressures.csv m2kcli uart $uri -i device=2 baud_rate=9600 parity=none bits_number=8 stop_bits=1 -w data= flow=$(m2kcli uart $uri -i device=3 baud_rate=9600 parity=none bits_number=8 stop_bits=1 -r bytes_number=12 format=number) byte4=$(echo $flow | cut -d' ' -f4) byte5=$(echo $flow | cut -d' ' -f5) byte6=$(echo $flow | cut -d' ' -f6) byte7=$(echo $flow | cut -d' ' -f7) byte8=$(echo $flow | cut -d' ' -f8) byte9=$(echo $flow | cut -d' ' -f9) byte10=$(echo $flow | cut -d' ' -f10) byte111=$(echo $flow | cut -d' ' -f11) byte12=$(echo $flow | cut -d' ' -f12) echo "$count;$byte4; $byte5; $byte6; $byte7; $byte8; $byte9; $byte10; $byte111; $byte12;" >> output1.csv sleep $ts count=$((count+1)) done
so after succeeding with standalone datalogging for both analog and I2C sensors, I am trying to perform standalone datalogging of a UART sensor in addition to both I2C and analog readings at the same time, but I am really struggling with UART and bit confused too. I am not sure if should use the UART command or the UART terminal or both of them, can you help me with that? taking into consideration that to pull some readings from the uart sensor the pulling message is: 110101ED
thanks a lot for helping.