[Swlug] Entertaining error.

Scott wanted_saucy320 at simplelogin.com
Fri Jul 19 06:25:46 UTC 2024


Hi Rhys,

I’m not super well-versed in microcontrollers, but I’m fairly sure the Pi Pico should have some onboard flash storage. Perhaps you could build in some procedure to write calibration data to the flash once and then read it on subsequent bootups?

Kind Regards,
Scott

> On 18 Jul 2024, at 11:39 PM, Rhys Sage via Swlug - swlug at mailman.lug.org.uk <swlug_at_mailman_lug_org_uk_llucvg at simplelogin.co> wrote:
> 
> 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
> 
> --
> Swlug mailing list
> Swlug at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/swlug


More information about the Swlug mailing list