Avatar for Adam

Adam

Member since Sep 2016 • Last active Oct 2016
  • 2 conversations
  • 7 comments

Most recent activity

  • in General
    Avatar for Adam

    perfect! the latest commit has completely fixed my issue, consider this issue solved.

    thanks all!

    • 11 comments
    • 716 views
  • in General
    Avatar for Adam

    I thought the same thing, but for some reason panasonic tvs use 35000 according to https://github.com/z3t0/Arduino-IRremote­/blob/master/ir_Panasonic.cpp#L24 (or I've completely misunderstood!)

    that's great news that's you've found an issue, thanks for taking the time to look into this

  • in General
    Avatar for Adam

    to make things stranger~, I generated the pwm data directly from https://github.com/z3t0/Arduino-IRremote­ instead of recording it. The same data and frequency also work correctly on an Arduino mega 2560.

    I'll try recording with the wifi. Maybe it's time to invest in a scope :)

    thanks for all the help!

  • in General
    Avatar for Adam

    great idea!

    Just tried setting the wifi to the system clock speed as the pico with

    console.log(E.setClock({M:8, N:336, P:4, Q:7, PCLK1:2, PCLK2:4}));
    
    prints 84000000
    

    but unfortunately it made no difference.

  • in General
    Avatar for Adam

    Hello :)

    I'm having a bit of trouble with the Espruino Wifi pwm pins. My aim is to control my TV via infrared.

    Running the code below with the same LED on a Pico has a 100% success rate of powering on my TV, however the Wifi is only able to work 3/10 times.

    As far as I can tell from the board pinout, A5 and A6 have the same features for both the pico and wifi.

    Both boards are running 1v87.

    function on() {
      var command = new Float32Array(
        [
          3.502,
          1.75,
          0.502
          ...etc
        ]
      );
    
      emit(command, A5, A6);
    }
    
    function emit(command, pinOne, pinTwo) {
      analogWrite(pinOne,0.9,{freq:35000});
      digitalPulse(pinTwo, 1, command);
      digitalPulse(pinTwo, 1, 0);
      analogWrite(pinOne,0,{freq:35000});
    }
    

    Is it possible that the faster cpu in the wifi is breaking the PWM timings?

  • in General
    Avatar for Adam

    ahhh the duty cycle, that was my problem, thank you!

    I also had to replace the initial start value with 0.

    analogWrite(A5, 0.5,{freq: 35000});
    digitalPulse(A6, 0, command);
    digitalPulse(A6, 1, 0);
    
  • in General
    Avatar for Adam

    Hello,

    I'm having some trouble getting infrared to correctly transmit from the Pico. Using the same PWM data (microseconds) and components I'm able to see it working using an arduino.

    The Pico is running 1v87 and I was unable to get the Pico infrared example transmitting (receiving is working and also reads the same values as the arudino).

    Minimal arduino sketch based on Arduino-IRremote

    [#include](http://forum.espruino.com/sea­rch/?q=%23include) <Arduino.h>
    
    [#define](http://forum.espruino.com/sear­ch/?q=%23define) SYSCLOCK  16000000
    [#define](http://forum.espruino.com/sear­ch/?q=%23define) IR_USE_TIMER2 
    
    unsigned int powerOn[] = { 
      3502,
      1750,
      etc...
      0
    };
    
    void setPwmFrequency(int khz) {
      const uint8_t pwmval = SYSCLOCK / 2000 / (khz); 
      TCCR2A = _BV(WGM20); 
      TCCR2B = _BV(WGM22) | _BV(CS20); 
      OCR2A = pwmval; 
      OCR2B = pwmval / 3;
    }
    
    void enablePwm() {
      (TCCR2A |= _BV(COM2B1));
    }
    
    void disablePwm() {
      (TCCR2A &= ~(_BV(COM2B1)));
    }
    
    void sendCommand(unsigned int command[], unsigned int size) {
      for (signed int i = 0; i < size - 1; i = i + 2) {
        enablePwm();
        delayMicroseconds(command[i]);
        disablePwm();
        delayMicroseconds(command[i + 1]);
      }
      disablePwm();
    }
    
    void setup() {
      pinMode(9, OUTPUT);
      digitalWrite(9, LOW); 
      setPwmFrequency(35);
    }
    
    void loop() {
      signed int size = sizeof(powerOn)/sizeof(int);
      sendCommand(powerOn, size);
      delay(5000);
    }
    

    Pico code

    function toMillis(i) {
       return i / 1000;
    }
    
    var powerOn = [
      3502,
      1750,
      etc...
      0
    ].map(toMillis);
    
    analogWrite(A5, 1, {freq:35000});
    digitalPulse(A6, 1, powerOn);
    digitalPulse(A6, 1, 0);
    analogWrite(A5, 0, {freq:35000}); // without this the IR LED never turns off
    

    Unfortunately I don't have an oscilloscope at hand to see what A5/A6 are actually outputting :(
    Am I missing something obvious?

    Thanks!

Actions