Conversion code from pyboard
-
Hi,
I use the following code on my pyboard:import array
import pyb
import utime
import timetime.sleep(2)
adc1=pyb.ADC(pyb.Pin.board.Y12)
buf1=array.array('H',bytearray(40000))
tim=pyb.Timer(6, freq=2000)
adc1.read_timed(buf1,tim)with open('chanel1.dash','w') as f:
for val in buf1:
s1 = str(val)
f.write(s1+'\n')And I want to adapt it and apply it on my wipy.
I wrote this:import array
import time
import os
from machine import SD
sd=SD()
os.mount(sd,'/sd')time.sleep(2)
from machine import ADC
adc=ADC()
adc1=adc.channel(pin='P13')buf1=array.array('H',bytearray(5000))
from machine import Timer
tim=Timer(6, mode=Timer.PERIODIC, width=32)
tim.channel(Timer.A, freq=1000, polarity=Timer.POSITIVE)
adc1.read_timed(buf1,tim)with open('/sd/chanel1.dash','w') as f:
for val in buf1:
s1 = str(val)
f.write(s1+'\n')But it's not working... it tells me "cannot create Timer instance"(line 15)
One of you may be know how to solve this ?
And someone know what is the limit size that I can put for the buffer ? It seems like there is some problem of allocation as well.
Also, I think that the 'read_timed' command doesn't exist for the Wipy..or at least I havn't seen it in the documentationThank you
-
look here
https://docs.pycom.io/pycom_esp32/library/machine.Timer.html
https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/timers.htmlno
read_timeddoes not exist please add this in
https://forum.pycom.io/topic/433/features-wish-list
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login