Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Conversion code from pyboard

    Scheduled Pinned Locked Moved WiPy 2&3
    2 Posts 2 Posters 954 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      Meide
      last edited by Meide

      Hi,
      I use the following code on my pyboard:

      import array
      import pyb
      import utime
      import time

      time.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 documentation

      Thank you

      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @Meide
        last edited by livius

        @Meide

        look here
        https://docs.pycom.io/pycom_esp32/library/machine.Timer.html
        https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/timers.html

        no read_timed does not exist please add this in
        https://forum.pycom.io/topic/433/features-wish-list

        think about people first, then computers

        1 Reply Last reply Reply Quote 0

        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
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom