1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

led MATRIX CURRENT DRAW

Discussion in 'Microcontrollers' started by MrDEB, Oct 4, 2012.

  1. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    Mrdeb if you are setting a port like
    PORTB = 240 that's hard to see what's happening so this would be better PORTB = %11110000

    But if your testing a number

    Code (text):
    If X= 240 then
    TX
    endif  
    that's easy to see

    Say TX is sending 240 it will send the byte 11110000 out one bit at a time
     
    Last edited: Oct 29, 2012
  2. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,201
    Likes:
    111
    Location:
    Seattle, WA
    ONLINE
  3. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    link does not work?
    BUT I am just wondering if for example
    instead of writing tx is sending one byte at a time just have tx = 240 instead of tx = %11110000
    just being inquisitive. I got the idea from looking at say the TETRIS code with LOTS of const arrays with 16 bit words.
    Will go back to my matrix and see about an example
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,201
    Likes:
    111
    Location:
    Seattle, WA
    ONLINE

    [MODNOTE]Its against the rules to be abusive to other members[/MODNOTE]
     
    Last edited by a moderator: Oct 29, 2012
  6. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    Page not found

    Link does not work!! as I stated but adding more chips is not my goal.
    You have to forgive JonSea or Mrdebsnightmare or what ever the poster goes by. They don't know how to treat people so they resort to abuse on the web.
     
  7. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    The best way to do this would be call Right, Left , Stop. And used what you said you had working

    Code (text):

    While true
        If Stop= 100 then
            display Stop
       elseif Right = 150 then
            display Right
       elseif Left = 200 then
            display Left
       else
         display green
     endif
    wend
     
     
  8. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    Post 172 I addressed the problem with using the 7555 so that idea in this project is out. Two bike riders would screw up the process.
    Rioght now trying to figure out how to implement the Swordfish Manchester code. Found several examples and they are outputting the data on the TX RX pins.
    Am trying to configure it to output on C3 (convenient to use on the Tap28). Just plug in the transmitter as the pins all line up correctly.
    Thinking of assigning the Usart output to C3 but not sure if that's correct procedure. Have an issue with the Junebug so using the Pickit2 only (was hoping to use both.)
    Will post my progress if any.
     
  9. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    I would make a sub called Get TX you don't need Manchester Just let the transmitter send like 100 small delay 100 small delay 100 Three times in a roll do the same for next state. 150 3 in a roll.

    So here what happens you press stop Your receiver get's a 100 it starts counting to 3 it get's 100 there two of them it gets 100 we have a stop.

    So now it wait till a new number come in It gets a 200 three times it changes to the green leds ok.

    So now if it get's a 100 then a 200 then 100 it goes and waits till it get's 3 in a row 100 100 100 do something 100 200 100 error look agin.
     
  10. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    progress so far

    Here is what I have but your idea sounds easier for sure. Got the call for dinner so will get back at it after dinner.
    Code (text):

    // if device and clock are omitted, then the compiler defaults to
    // 18F452 @ 20MHz - they are just used here for clarity...
    Device = 18F2420
    Clock = 20

    // uses USART library...
    Include "USART.bas"
    Include "convert.bas"
    Include "manchester.bas"

    // working variables...          
    Dim ValueWord As Word
    Dim ValueByte As Byte
    Dim tx_out As PORTC.3
    Dim led As PORTC.0
    Dim x As Word


    Output (tx_out)
    Output (led)
    led = 0
    tx_out = 0
    While 1 = 1
    For x = 0 To 10    // cycle through 11 times
    // encode a value, display the result...
    //SetBaudrate(br19200)
    ValueByte = %00000000
    ValueWord = Manchester.Encode(ValueByte)
    //Tx_out =  (ValueByte, 8)
    USART.Write("Encode ", BinToStr(ValueWord, 16), 13, 10)
      PORTC.3 = ValueByte  // send data out on c3
      If tx_out = 1 Then
      led = 1
      else led = 0
      delayms(2000)
     
      End If
       Next
      Wend
      {
    // decode and display...

    If Manchester.Decode(ValueWord, ValueByte) Then
       USART.Write("Decode ", BinToStr(ValueByte, 8), 13, 10)
    Else
       USART.Write("ERROR!", 13, 10)
    EndIf
     
     
  11. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    Reread your idea but need to contemplate a second transmitter unless I use say 400,500,600 for second transmitter and 100,200,300 for second etc. (could go 100, 150, 200 etc.
    will ponder this solution but am concerned about second or third transmitter??
     
  12. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,869
    Likes:
    144
    Location:
    morristown,tn
    You don't what to send data at 19200 thats way to fast these things were made for more slower transmit 2400 is as fast as most us them

    And It's not hard to add a id to what I showed you I figure you get one working first then add to it.

    Say 1 to 40 id to start then if you need more just make bigger numbers.
     
    Last edited: Oct 29, 2012
  13. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    A possiable solution I found

    Searching on the web and found two very similar projects.
    http://www.serasidis.gr/circuits/RF_remote_control/RF_remote_control.htm


    one uses a avr but a PIC could be used and the second project http://www.coolcircuit.com/project/rf_remote/ uses a 12f pic but a 10F200 could maybe be used (smaller footprint??)
    Looking over the code which is in C I get a slight idea what the code is doing.
    The two projects are viable and the second one is exactly what I want to do, three switches but two would work as well.
     
  14. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    I recall an encoder / decoder chip (Jonsea jogged my memory when he mentioned encoder / decoder) so I did some searching and found an application that would not require a PIC on the transmitter side of project.
    Reading the description I think? get 255 different combinations depending on the status of the A0 - A7 (need to read data sheet further etc.
     
  15. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,201
    Likes:
    111
    Location:
    Seattle, WA
    ONLINE
    Please just forget every suggestion I've made and do not mention my name again.

    You are not designing software for the Mars rover. There are dozens of different ways to accomplish your goal, any one of which would work well if you make the effort to understand it.
     
  16. MrDEB

    MrDEB Active Member

    Joined:
    Apr 16, 2007
    Messages:
    4,414
    Likes:
    23
    The decoder /encoder suggestion I understand and it accomplishes the one goal of minimal parts count.
    Your suggestion of encoder / decoder made me realize that there is another solution. If one has several solutions to a problem then a choice can be made with a hopefully better result.
    I realize this is not for a Mars Rover and YES I am making an attempt to understand all that I have posted by printing out the source code and following what each line of code does.
    YES the two projects I posted were using an AVR or PIC and in C but looking over the code I can see the similarities of C to Swordfish.
     

Share This Page