Menu

Driving a bunch of relays using one pin on pic

Moto Geek
2017-11-19
2018-04-28
<< < 1 2 (Page 2 of 2)
  • louie

    louie - 2018-04-22

    damn i'm not getting email notification.
    whatever. yeah i already went through quite a nightmare with the flashAVR.bat command. in the end i just scrubbed the G+stool and copied the script from the arduino IDE and i finally got the blink on. it took several hours.
    i'm using SynWrite 22.2290 on win7-64. it doesn't work if i hit the HEX/FLASH button so i gotta hit HEX first and then hit FLASH.
    ok i'll try to duplicate what you got on the term window.....
    [30 minutes later...]
    ok on the term window i get this:
    FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    repeating sequence of 24 bytes of FF and 88 bytes of 0. it's supposed to be 24 bytes of FF and 24 bytes of 0. watching the term screen what i see is that it sends a packet of 54 bytes, then 2 more bytes, then 54 bytes, then 2..... and every other packet is 24 bytes FF with 30 bytes of 0.

     

    Last edit: louie 2018-04-22
  • mmotte

    mmotte - 2018-04-22

    Mike,
    You have win 7 , the GreatCow IDE Synwrite should compile and flash your mega2560 without problems. The hex/Flash button should work. there is only two little things to look for in the flashAVR.bat file.
    First we need to know the port that the Mega2560 is on?
    In windows 7 you go to "Startkey> control Panel>Device manager>Ports(Com and Lpt)> Arduino Mega 2560 (com13)" Com13 is the port mine is on.

    Next you open Synwrite GCB IDE and click on the GCBasic button in the middle of the second toolbar at the top. Fisrt selection is "Edit avr programmer batchfile". Click on that and it brings the flashAVR.bat file to the IDE.
    Line 25 is blue and mine has ""AVRdude\avrdude.exe" -B 5 -c USBasp -P Usb -p AT%2 -U flash:w:%1:i".
    Put "REM" in front of that line and it turns green = comment
    Cursor down to line 48 " "AVRdude\avrdude.exe" -c wiring -p m2560 -P COM6 -b 115200 -D -U flash:w:%1:i"
    Remove the "rem " from the front.
    Change the -P COM6 to -P COM13 or what ever your port is that you discovered above.
    Save it.

    Now goto File Open ... GCB@Syn98/GreatCowBasic/demos/ledsolutions/simple blink on off solutions/ Blink LED mega328p.gcb

    Modilfy the processor line to #chip mega2560, 16
    Modify the led port to PortB.7 in both places
    Save as BlinkLEDmega2560.gcb
    Press Hex/Flash button and it should compile and load
    led is flashing.

    Should be that easy.

    I am not especially happy with what is shown coming to the terminal. But I will attach what I have for now . I need to get the logic analyzer out and check.

    GL
    Mike

     
    • louie

      louie - 2018-04-22

      what i been doin is plug in the board, check with DM for the port #, then hit IDE Tools, Customize External tools, and edit the script for the FLASH button for avrdude on the corresponding port.
      now i done the edits you described. thanx.
      so yeah i got the blink working. and i loaded the DMX routine and what i got on the terminal screen is a pattern of
      1st- packet of 54 bytes of 0, followed by 2 more 0s.
      2nd- packet of 54 bytes, 24 bytes FF and 30 bytes of 0,then 2 more 0s.
      i'll load the file you provided and see what happens.
      thanx a bunch i really appreciate the assistance.

       
    • louie

      louie - 2018-04-22

      ok i loaded your code and it's better. 20 byte packets.
      00 C0 FF FF FF C0 C0..... followed by
      00 C0 C0 C0 C0 C0 C0.....
      although the relay board i'm usin still does not react even though it did when i was usin arduino code.

       
  • mmotte

    mmotte - 2018-04-22

    Mike,
    I don't know what the C0's are. I think they are remanents of turning the serial usart port on and off. i have tried sending sequential numbers and they all start with C_ and the second hex digit increments with the numbers. It is a puzzle.

    i am no atmel expert. So maybe there is somthing I haven't read about on the serial port. I did read that the serial port has to finish sending the shiftegister and the buffer if there is data there before letting go of the output port.

    I do have a logic analyzer but need time to get it connected.

    I was going to try it on another channel of the 2560 and see if the usb chip is interfereing.

    BR
    Mike

     
    • louie

      louie - 2018-04-22

      HOLY #%$! i just opened and loaded a previous version of the program and PRESTO it's working! and i have NO IDEA WHY. it's the exact same code i was using this am and it didn't work then. WTF. i'm gonna check on the terminal.....
      [1 minute later]
      ok it's doing this:
      00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      55-byte packets. i'm gonna check the code......

      [9:10pm PST]
      ok here's a statement in my code that's different from your MotoGeekV_2560 version.
      UCSR0C = 0b00001111 ' Async, no parity, 2 stop bits, 8 bits

      [9:17pm PST]
      and here's something else that's different:
      wait 100 ms 'BREAK - 100ms
      set DMXout on
      wait 100 ms 'MARK AFTER BREAK (MAB) - 100ms

      [9:19]
      and this:
      HSerSend 0 'STARTCODE (always 0)
      set DMXout on
      wait 100 ms 'Mark Time Between Frames (MTBF) - 100ms
      set DMXout off
      for Zz = 1 to MaxChan 'Channel 1 - (MaxChan)

      [9:24]
      this too:
      set DMXout on 'DMX MARK condition (DMX idle)
      wait 100 ms 'MARK for at least 100ms
      set LED off
      end sub

      so that's it. everything else is the same. i'm gonna start editing and narrow it down.

      [9:41]
      well i've narrowed it down now. THIS was it:
      UCSR0C = 0b00001111
      i've got the Character Size bit set for a 9-bit characters! how ironic that i posted a question about why MotoGeek had set his serial encoding to 9 bits, and it turned out to be the correct encoding for the mega as well.

      [9:47]
      yup that was it alright. if ya just change that one statement it aughta work.
      can't believe i finally got it goin on.
      THANX MIKE you kept me goin :-)

       

      Last edit: louie 2018-04-22
  • Moto Geek

    Moto Geek - 2018-04-24

    Post a video... Post a video... I like to see relays clacking. I'm glad you got this working. I have found quite a few good uses for GCB and DMX. I just finished a sound to DMX light controller using a 16f1825 and an MSGEQ7. I'll try and post a video of that one too, really cool and thanks to GCB, very fast.

     
    • kent_twt4

      kent_twt4 - 2018-04-24

      Yes, more videos! Since you brought up the DMX/MSGEQ7, be sure to start a new thread, as I have question about the MSGEQ7.

       
  • Moto Geek

    Moto Geek - 2018-04-26

    I will start a new thread for that, but just to show you quickly, here is the simple code to read the msgeq7 to get you started. I used the values in the array to do some cool dmx stuff.

    Lots of good explanation here... http://www.eetimes.com/author.asp?doc_id=1323030

    #define Eq7AD portC.3           'Pin 7 C.3, AN7 - EQ7 output
    #define Eq7Stb portA.0          'Pin 13 A.0 - EQ7 Strobe
    #define Eq7Rst portA.1          'Pin 12 A.1 - EQ7 Reset
    
    dir Eq7AD in
    dir Eq7Rst out
    dir Eq7Stb out
    
    set Eq7Rst off
    set Eq7Stb on
    
    dim EqValue(7)
    
    do
    'call read MSGEQ7 sub
    RdMSGEQ7
    'do stuff with array values
    loop
    
    sub RdMSGEQ7
    set Eq7Rst on
    wait 1 us
    set Eq7Rst off
    wait 75 us
    
    for Eq = 1 to 7
    set Eq7Stb off
    wait 40 us
    EqValue(Eq) = ReadAD(AN7)
    if EqValue(Eq) < 30 then EqValue(Eq) = 0 'filter noise
    set Eq7Stb on
    wait 40 us
    next Eq
    end sub
    
     
    • louie

      louie - 2018-04-28

      ok the video's up. i started my own thread: DMX transmission with Great Cow BASIC on arduino

       

      Last edit: louie 2018-04-28
  • kent_twt4

    kent_twt4 - 2018-04-26

    Oh, I had the MSGEQ7 going, been several years ago. It mostly is how the low bands 63Hz and 160Hz? seemed to have very little resolution, but for sure the 63Hz. If I take it back up again, may have to use some promotion to push the scale up to match what I hear.

    Didn't know if you tried to improve the response for those low Hz somehow? or maybe it is just the audio chip of my computer?

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.