Shop OBEX P1 Docs P2 Docs Learn Events
Reading Input Value - Page 2 — Parallax Forums

Reading Input Value

24

Comments

  • DHoganDHogan Posts: 40
    edited 2012-01-22 10:51
    Hi Zoot,

    I've tried the modified code and still no success. I did change the values of Lock, Unlock, Trunk and Panic from LEDOFF to LEDON to verify they would light up, and they did, so there is good comm between the pins and LEDs. Also, I did use "Program" when I downloaded the code, and now instead of no lights on the LEDS, they are randomly lighting up each time I power cycle the unit (all blinking, some on/some off, etc.) I tried changing between MSB and LSB in the code, but got the same results. I think this might be good news though.

    I realized I never gave you my working conditions (OS, SX/B Key version, etc.) so I've put those below and also the message/LED combos. I've also attached a picture of what I'm working on so you have a mind's eye of what it looks like as well. Additionally, attached is a picture of the IRC-Frequencies from the first version of the code, in case it would help.

    Working conditions:
    1) Windows 7 x64
    2) SX Key Editor 3.3.0 R2
    3) SX Key USB Rev B - Note: Just a reminder that the debugger does not work.
    4) SX28AC/DP-G

    Message/LED combos:
    Lock = 1001_1111
    Unlock = 1010_1111
    Trunk = 1011_0111
    Panic = 1011_1011

    Many thanks again.
    1024 x 576 - 63K
    1024 x 681 - 84K
    1024 x 681 - 99K
    1024 x 681 - 122K
  • ZootZoot Posts: 2,227
    edited 2012-01-22 11:33
    Which version of SX/B? See my earlier post.

    I had thought you were going to use a resonator. I would not run this off the SX-Key clock nor would I run it from the internal oscillator.

    Last but not least... schematic? Is the detector in the long tube?
  • ZootZoot Posts: 2,227
    edited 2012-01-22 12:14
    Dillon -- I've been mulling this over and the behavior you describe doesn't add up, i.e., I might expect "wrong" messages, and I might expect no messages, but random lighting points to something else.

    So... let's try a few things, one a time, so we can eliminate possible sources of the problem.

    First, are you clear on the difference between "PROGRAM" and "RUN"? Program burns the code into the SX and then presumes that a clock source (resonator, crystal, etc) is actually hooked up to OSC1/OSC2 OR that the program is using the internal 4mhz oscillator. The circuit provides the clock. Do not use the internal oscillator, it will not be accurate enough, I don't think for your task. So if you "PROGRAM" and DO NOT have a resonator installed, forget it, your SX won't clock right.

    If you "RUN" then the SX-Key/Blitz provides a very accurate clock (basically, it simulates a resonator/crystal) and you MUST have any external resonator or crystal in the circuit removed.

    So do one or the other for this test. My preference would be to PROGRAM the SX, and then remove the Key and let the circuit run off an external resonator, but either way should be OK for this test.

    The attached program has your messages copied in and some extra start up code at the beginning. If you PROGRAM this and use a resonator or RUN it and let the SX-Key clock the chip, this would I would expect to see upon startup:

    - each LED lights individually, in order, for 1 second, then off for 1 second

    If you DON'T see that on reset (the time seems really fast/slow or not consistent), stop, the rest is moot.

    Lastly, I still would like to know what version of the SX/B compiler you are using. You can see the version if you look at the .SRC file generated from your .SXB file -- at the top will be version info like this:
      ;  *** COMPILED WITH SX/B VERSION 2.00.31  04/08/2010 ***
    

    If you don't have 2.00.31, don't worry about installing yet -- just use the .SRC file (pre-compiled) that is attached instead of the .SXB file.
  • DHoganDHogan Posts: 40
    edited 2012-01-22 17:09
    Hi Zoot,

    Thank you very much for the information and explanations regarding PROGRAM and RUN. Very informative and helpful. I did as you suggested and did PROGRAM the SX, left the resonator in, and pulled the SX-Key. When I did PROGRAM the code the first time, I got three errors in the code. First, the BANK __DEFAULT in Line 150 was shown as an INVALID PARAMETER. Second, in lines 292,293, 302 & 303 (LedPort = LedPort & ~LedPortMask, PAUSE_250), an error of INVALID NUMBER OF PARAMETERS was shown. I commented these lines out and ran the code. The LEDs did not light. I also tried pulling out the resonator and RUN it as well. I also tried using .SRC file. I got the version of the SX/B compiler (see below):

    ; *** COMPILED WITH SX/B VERSION 1.51.03 09/21/2006 ***

    I looked through the code and it all looks good. I'm not clear where the error can be.
  • ZootZoot Posts: 2,227
    edited 2012-01-22 18:34
    OK, we're getting somewhere :) First, don't comment out code. The code I've been posting compiles and runs here (that's why I asked about your compiler version). The pre-SXB 2.x compiler will not work for your code (PULSIN has changes, among other things). So I'm only providing the .SRC file -- don't worry about compiling or installing SX/B 2.x yet.

    This version does not read the message detector. All it does is light up each led for one second, followed by a one second "off" time, then the next led, and so on. Over and over.

    Let's try to save time here -- if it doesn't behave as described above, just report that it failed and we'll take it from there. I want you to do all of the following exactly and report your results:

    - remove any resonator or crystal from the circuit
    - make sure the ANODE (+) lead of an LED is hooked up -- through a resistor -- to RB.1, RB.2, RB.3, RB.4
    - open the .SRC file attached to this forum post and RUN it -- this will make the SX-Key generate the clock signal

    If all the above is true, and it fails, get back on the forum. I'll be close by tonight as I'm working on some of my own projects.
  • DHoganDHogan Posts: 40
    edited 2012-01-23 07:02
    Hi Zoot,

    OK, I did all as requested:

    - pulled the resonator from the circuit
    - verified the ANODE lead was hooked up through a resistor to RB.1, 2, 3 & 4
    - opened the .SRC file and did RUN it

    The results I got were that all four LEDs light up at the same time and remain lit. I power cycled and checked it again and got the same results. I did not get any errors when the code ran.

    Many thanks again for your help and let me know if there is any additional information I can provide.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 07:49
    That is officially WACKY. Let me mull this over for a few minutes.

    You left the SX-Key connected, right?
  • DHoganDHogan Posts: 40
    edited 2012-01-23 07:54
    Concur that this is wacky :-)

    I have attached a schematic.

    I did leave the SX-Key connected.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 08:16
    Glad you posted the schematic. Why do you have pullups to the anodes of the LEDs? I can see no reason for this? I would think this would leave your leds lit mostly, and sometimes they might go off if the pin is driven low. Unless there some reason for these that I don't know of, I would remove the 10k pullsup from 5v to the 4 LED/RB pin connections.
  • DHoganDHogan Posts: 40
    edited 2012-01-23 09:17
    The 10k pullups are just used for an ounce of prevention, but they are not required. I just pulled them and ran the code again (leaving in the SX-Key), but got the same results (all LEDs light up and stay on).
  • ZootZoot Posts: 2,227
    edited 2012-01-23 09:21
    You don't need them and they don't prevent anything. The 330ohm resistors between the anodes of the LEDs and the SX pins are plenty of protection against too much current on the pins. Leave them off -- they can only interfere with the LEDs being fully "on" or fully "off" depending on the high/low state of the SX pin.

    But something is odd. The code I posted should only light up one LED at a time, for one second, each LED in turn then repeat.

    Try installing your 4mhz resonator, do a PROGRAM from the .SRC file and let me know what happens. Make sure the Key is disconnected then power up the circuit. Can't hurt to make sure you also have an appropriately sized resistor across the oscillator pins (between OSC1 and OSC2). 1Mohm would be fine.
  • DHoganDHogan Posts: 40
    edited 2012-01-23 09:42
    Ok, here are the steps I took:

    1) put the 4MHz resonator back in
    2) pulled the 10k resistors
    3) put in a 1Mohm resistor across OSC1 & OSC2
    4) put the SX-Key in and did a PROGRAM from the .SRC file. Pulled the SX-Key, power cycled the unit

    The LED lights remain off, no activity
  • ZootZoot Posts: 2,227
    edited 2012-01-23 09:55
  • DHoganDHogan Posts: 40
    edited 2012-01-23 10:29
    Hi Zoot,

    Same result. The LED's do not light up.
  • DHoganDHogan Posts: 40
    edited 2012-01-23 11:17
    Still no activity with the 04B version. Just to make sure everything was still attached correctly, I ran the attached code we made in house. It's very random but does produce LED activity.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 11:23
    Something is off here. Your code, btw, uses the internal oscillator. It will never be accurate enough for your pulses, but to see if we can narrow this down, try running the attached. Remove the resonator and osc1/osc2 resistor and use PROGRAM.
  • DHoganDHogan Posts: 40
    edited 2012-01-23 11:38
    I used PROGRAM and an error occurred. Please see attached.

    I did remove the resonator, osc1/osc2 resistor and used PROGRAM
    1024 x 576 - 65K
  • ZootZoot Posts: 2,227
    edited 2012-01-23 12:02
    Try this, same way (no res, no resistor, PROGRAM).
  • DHoganDHogan Posts: 40
    edited 2012-01-23 12:20
    OK, (no res, no resistor, PROGRAM) this time they all light up at the same time. I also powered off, then back on and same result, they all light up.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 12:27
    OK, now try this. Again, make sure Key is disconnected and use PROGRAM.
  • DHoganDHogan Posts: 40
    edited 2012-01-23 13:07
    They still all light, but the difference is the LEDs are dimmer in this version of code, than the D version (about half the brightness). I'm not sure if this helps but just want to tell you every observation.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 13:13
    I don't think the chip is getting clocked correctly. I'm going to be out of the office for an hour or so; when I get back we'll see what step to take next that would be genuinely productive. This is very very very odd, bordering on unexplainable.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 14:11
    OK, try this one :) It's SX/B, but nothing special that would matter between compilers.

    Use PROGRAM. Make sure resonator, osc1/osc2 resistor, SX-Key are removed after programming. Then power cycle.

    The single LED on RB.1 should flash over and over -- 1/4 second on, 1/4 second off. In fact, if you hook your scope up to RB.1 you should see a pretty good 2hz square wave (+/- 10% given tolerances of the internal RC oscillator).

    If this doesn't work then I would suspect you have some kind of hardware problem (incorrect wiring, bad SX, something).
  • DHoganDHogan Posts: 40
    edited 2012-01-23 14:40
    That is working!! The LED on RB.1 is flashing.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 14:50
    OK, try this one -- each led (RB.1-RB.4) lights up individually for 1/4 second, then 1/4 second off, then the next led... over and over.
  • DHoganDHogan Posts: 40
    edited 2012-01-23 14:55
    Awesome!! Each LED is lighting up for 1/4 second and looping over and over.
  • ZootZoot Posts: 2,227
    edited 2012-01-23 15:05
    Still doesn't make sense, as the others should have worked then, too... but let's keep poking along :)

    Try this one. Use RUN and leave the SX-Key connected. In the DEVICE window, make sure the clock speed comes up as 4mhz. It should behave exactly as Test02 did.
  • DHoganDHogan Posts: 40
    edited 2012-01-24 06:32
    Hi Zoot,

    That worked! The LED's are individually flashing faster, over and over again.
  • ZootZoot Posts: 2,227
    edited 2012-01-24 06:40
    That was with the SX-Key generating the 4mhz clock (key connected, "RUN")? Is that correct? If so, I'll post more code for you a little bit later this morning (I'm out of here till about 9am MT). Hopefully we can nail this down today :)
Sign In or Register to comment.