Author Topic: PWM not a defined PinMode  (Read 215 times)

jflores

  • Newbie
  • *
  • Posts: 27
    • View Profile
PWM not a defined PinMode
« on: December 05, 2016, 07:25:38 pm »
Sorry if it looks like spam but I'm still having some issues. I wrote the following code to make a sensor send a message over Sigfox, the thing is I wanted to use a PWM instead of a RiseEvent, I believe I'm wasting a lot of power doing this.
Code: [Select]
Define PinMode Pin0 As AnalogRead

Class AnalogRead
   
    Shared Event GetPin1Analog() RaiseEvent Every 4 Seconds
       
        Dim value As Short
        value = Pin0 // Read the pin. This activates the ADC
        'Return value // Return value in millivolts
        Led2 = True
        Thread.Sleep(value)
        Led2 = False
        If value > 1600 Then 
            Led3 = True
            Dim sfData As ListOfByte = New ListOfByte
            'Add data to Sigfox message (up to 12 bytes)
            sfData.Add(0x40)
            sfData.Add(0x87)
            sfData.Add(0x1a)
            sfData.Add(0x54)
            Lplan.SigfoxRadioZone(SigfoxRadioZone.FCC_US)
            Lplan.Sigfox(sfData)
            Led3 = False
        End If
    End Event
End Class

It works fine, the issue is using the Pwm as a Pin mode.

Therefore, I can't run this sample either:
Code: [Select]
01 Define PinMode Pin0 As PwmOutput
02
03 Public Sub SetPwm()
04 Dim pwm1kHz As Pwm
05 pwm1kHz = Pwm.Create(1000) // create PWM with 1000µs period
06 pwm1kHz.SetDutyCycle(Pin0, 200) // set PWM to 20% duty cycle on Pin0
07 pwm1kHz.Start() // start PWM
08 End Sub

Also, I went through McScript but I don't totally get how to convert the Short (string values would help too) value to bytes, I'd appreciate any reference for this. Thanks in advance!
« Last Edit: December 06, 2016, 05:48:25 pm by jflores »

Share on Facebook Share on Twitter


mc-John

  • Global Moderator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: PWM not a defined PinMode
« Reply #1 on: December 06, 2016, 09:23:53 pm »
Sorry but PWM is currently not supported. See release notes.
It is low on the priority list