[Swlug] Entertaining error.

Rhys Sage rhys_sage at yahoo.com
Thu Jul 18 22:37:40 UTC 2024


My Pi Pico is producing readings from the 3 ADCs but I needed to calibrate the ADCs so I modified the code thusly...
import machine
import utime
analog_value = machine.ADC(0)
analog_value1 = machine.ADC(1)
analog_value2 = machine.ADC(2)
#zero values
correction = analog_value.read_u16()
correction1 = analog_value1.read_u16()
correction2 = analog_value2.read_u16()
while True:
    reading = int((analog_value.read_u16() - correction)/256)
    reading1 = int((analog_value1.read_u16() - correction1)/256)
    reading2 = int((analog_value2.read_u16() - correction2)/256)
    print("ADC 0: ",reading, " ADC 1 ", reading1, " ADC 2 ", reading2)
    utime.sleep(0.2)

Afterwards I realised that would not work in the real world. The plan for the ADCs is for each to read a patch of sunlight reflected off a white reflector in order to ascertain which is most illuminated by the sun. 

Two stepper motors will adjust the position of the assembly the ADCs are mounted on so that it will be able to track the sun precisely during the day.

I realised that as soon as the power goes off it will have to be re-aimed and re-calibrated. Better instead to use electronics and put presets on the LDRs in order to calibrate for optimal aim. Thus, when the sun comes up in the morning and the thing comes alive, it'll be able to find the perfect aiming point. 

Usual issue - I spend so much time on real life I have little to no time for programming projects. Out all day Tuesday, out all day today. Out all day tomorrow and Saturday. 

The ultimate aim of this project (which will include some 3D printed parts) will be to produce a device that can track the sun, focussed through a flat magnifier and aimed at a coin held in an insulated mount. I just want to see if I can melt the coin by the power of the sun though the tracking software will serve another project that's planned later down the line.

Rhys Sage



More information about the Swlug mailing list