Shop OBEX P1 Docs P2 Docs Learn Events
Damage to Counter — Parallax Forums

Damage to Counter

Hi all,

I was messing around the Synth.spin object to generate a frequency when a pin would go high, then i would set synth.spin to freq of 0 when the pin was low.
it was working fine while connected to a switch but when i left the input pin floating the frequency became slightly less than half that of expected, i havent scoped it yet but measured on a multimeter.

so i changed to counter B, it worked fine too until i floated the pin then bam, half frequencies again, ive rebooted the chip and reflashed but it remains half frequency, appears as if it has damaged the counters of that cog.

has anyone else seen this before?

code exerp below which was running in a new cog;

repeat
If Not ModeSelect 'Mode 0 Async / Mode 1 Sync
if Left_Button
Outa[DirPin] := 1
SpeedtoFrq 'Converts Speed(mm/sec) to calibrated frequency
Synth.Synth("A",PulsPin,20_000)
if Right_Button
IF not Right_Button & Left_Button
Synth.Synth("A",PulsPin,0)

Comments

  • I could not duplicate your finding.
    repeat
      if (ina[button] == 0)
        synth.synth("A", OutPin, 20_000)
      else
        synth.synth("A", OutPin, 0)
    

    It worked as expected. Using a 'scope, I saw either 20 kHz or 0. Disconnecting [button] left the OutPin at 20 kHz, reconnecting (actually, shorting to ground or 3.3) again behaved as expected.
    I even tied button to a potentiometer so I could put it right at threshold, continued to work correctly (either saw 20 kHz or 0).
  • Andrew.G wrote: »
    Hi all,

    I was messing around the Synth.spin object to generate a frequency when a pin would go high, then i would set synth.spin to freq of 0 when the pin was low.
    it was working fine while connected to a switch but when i left the input pin floating the frequency became slightly less than half that of expected, i havent scoped it yet but measured on a multimeter.

    so i changed to counter B, it worked fine too until i floated the pin then bam, half frequencies again, ive rebooted the chip and reflashed but it remains half frequency, appears as if it has damaged the counters of that cog.

    has anyone else seen this before?

    code exerp below which was running in a new cog;

    repeat
    If Not ModeSelect 'Mode 0 Async / Mode 1 Sync
    if Left_Button
    Outa[DirPin] := 1
    SpeedtoFrq 'Converts Speed(mm/sec) to calibrated frequency
    Synth.Synth("A",PulsPin,20_000)
    if Right_Button
    IF not Right_Button & Left_Button
    Synth.Synth("A",PulsPin,0)

    Could you post your entire SPIN file as a zip?

    File>Archive>Project


  • zip attached (although the code is incomplete)

    ill scope it tonight and post results.

    and try it with another cog.

    one thing i realised is my 0v is earth referenced, so floating an input pin i found results in excessive noise (the pin will not just float high but will change states)
  • well i got it to work.

    the problem was with the "IF not Right_Button & Left_Button" line

    changed the & to + and it runs fine.

    im not sure why or how i only noticed the issue after floating the pin, even on two occasions with counters A and B,
    and i definitely saw the correct frequency at least at one stage.

    attached was the scope shot of the issue (sorry for the screen grab didnt have a usb at the time). what i found was 20khz running for 1ms pulses, with a 1ms pause.


    i cant see why the propeller reacted as it did


    1267 x 950 - 240K
Sign In or Register to comment.