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

Junebug Assembly Tips

Discussion in 'Microcontrollers' started by Krumlink, Nov 5, 2007.

  1. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Session with Krumlink.

    Krumlink is using MCC18 and an inchworm+. We are using the 18F mostly for the free compiler. The code we used today was rather quickly ported from the 16F88 and the CCS midrange compiler to the 18F330 and MCC18. I mailed the 18F1330 code to Krumlink and we changed just enough to get it to run on the 18F1320. The delay code is way off.

    We started out with a program that blinked a single LED
    Code (text):

    #define ACT_LED            LATBbits.LATB2
    ...
    main()
    {
        while(1)
        {
             ACT_LED = 0;
             delay_ms(10);
             ACT_LED = 1;
             delay_ms(10);
        }
    }
     
    Code to blink the same LED using LATB existed in the loop but it was commented out.

    Code (text):
    //    LATB = 0x00;
    //    LATB = 0x04;
    I explained the relationship between each bit of port B and how LATB could be used to set it.
    Students are required to translate HEX digits to binary without thinking about it. Similar to learning math tables in grade school.
    Krumlink added a 2nd LED. I expained enough to get him to see how he could alternate them. In short order he had several LEDs doing interesting things. Too early to talk about muxing.... Need to cover the basics like flow, data types, math... first.

    For an assignment I asked Krumlink to use 6 LEDs (he is using the debugger) and create.

    x00000
    0x0000
    00x000
    000x00
    0000x0
    00000x
    0000x0
    000x00
    00x000
    0x0000

    then repeat.

    From installing the compiler to this point was 2.5 hours and I was bushed.

    But that was not enough to keep his busy so I sent him two examples of blinky code using for loops without any explaination. He is going to figure out what it does an how/why it does it. It is going to be a challange to keep him busy.
     
  2. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Helping Krumlink with his homework

    How to put this in the right light. I require Krumlink to do his own work. He can google for info and ask me questions. But I do not want him to post questions about his assignments on forums.

    Why?
    I would like to control his exposure to material/content.
    He nees to discover (think about) how things work.
    Examples code may be quick and dirty, I do not care to have such code posted.
    The example code may be borrowed from others who have not given us permission to post/publish it.
    I do not like donig dammage control.
    Up to now I did not provide any guidance in this area so I have no reason to be upset about Krumlinks last post asking for help with an assignment.

    I may relax this a bit after we cover the basics. For now I hope that everyone can understand and respect why it needs to be this way. If I wanted to write a textbook or publish a guide on the subject I would welcome comments and help.
     
  3. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    Well done both of you.

    I too wish to write a book and I'd love to collaborate on one.

    Edit: Here's the new Mongoose Poster.
     

    Attached Files:

    Last edited: Nov 13, 2007
  4. dave

    Dave New Member

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


     
  5. jeremygaughan

    jeremygaughan New Member

    Joined:
    Sep 26, 2007
    Messages:
    129
    Likes:
    1
    Location:
    Hot Springs, AR

    Hi again, I've got my programmer all put together and I am running into some trouble. I need some advice on where to start debugging this thing. I read the pic and the firmware appears to be there. I have run the traces and checked with a multimeter a bunch of times (and I'll do it a few more times) but my computer doesn't even make a "bink bonk" sound to say I've plugged something in. What would be the minimum number of connections that I need to make to at least get the computer to know I've plugged something in. For example would my computer recognize, power, data lines, and the crystal or does this thing have to be perfect to be recognized? At least I get a green light when I plug it in, but then again any monkey with 1 resistor and 1 led could do that.
     
  6. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    The crystal must be 20MHz and running with the 18pf to 22pf caps on the crystal.
    The 0.47 and 0.1 cap must be there, measure for 3.3V across the 0.47uf.
    And of course the USB connector and Ferrite bead have to be there.
    That's the bare minimum to get a USB connection.

    How did you wire it? Point to point, breadboard?
     
    Last edited: Nov 13, 2007
  7. jeremygaughan

    jeremygaughan New Member

    Joined:
    Sep 26, 2007
    Messages:
    129
    Likes:
    1
    Location:
    Hot Springs, AR
    I etched a PCB at home and used jumpers where necessary. I get 0.00v across the ".47". I have a 20 Mhz crystal and two disc caps that say "22.". For the ferrite bead I have a ring and the power wire is wrapped around 6 times. My first real doubt is the capacitors because I'm not sure 22. means 22pf.
    edit: I took the chip off the PCB and breadboarded it. It still gets 0.00 volts and no "bink bonk" on the computer. I'm going to have to try another programmer to install the firmware. I think that is the problem. The kit149 that I'm using gives a eeprom error. that I mentioned a few posts back. More when I have progress.
     
    Last edited: Nov 13, 2007
  8. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    It does sound like the PIC isn't programmed properly. I didn't think the K149 supported the 18F2550.
    Strangly the picall software needs the PGM pin pulled to GND, you could try holding down the pushbutton before plugging it in to the USB, see if the busy LED flashes.
     
    Last edited: Nov 13, 2007
  9. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    I had to think about that for a while.
    It sounds interesting what do you have in mind.
     
  10. Krumlink

    Krumlink New Member

    Joined:
    Aug 10, 2007
    Messages:
    2,080
    Likes:
    20
    Location:
    Michigan, USA
    Hey 3v0, I got a back and forth LED Scrolling thing working :)

    At my robotics meeting, it was really bad, because they were trying to get me to program the robot when I had no Idea what they were doing "add a if loop bla bla bla". They were trying to teach me something I had no experience with, so it was a very frustrating night.

    Then my internet went down, and my WIFI stopped working.
     
  11. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    We will get to "if" and all the other flow related concepts very soon. :)

    We had to get the tools working and cover the edit - compile - program - run cycle. Now that we have done that we can start with flow control and decision making.

    Good about getting the assignment done. If all goes well we can do more this afternoon.
     
  12. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    There are so many examples on the web, I'd like to organize them into a book or series of small periodicals. Nigels, Elmers, EPE and countless other PIC tutorials are excellent, with their permission we could reformat, update & modifiy them to something along the lines of the Junebug tutor to start.

    IMHO Simulators are great but there is something more exciting about flashing an actual LED.
     
  13. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    I think it would be useful to the same examples coded in C and assembler.

    I have to agree about flashing the LED. Interaction with the physical world makes embedded programming interesting.
     
  14. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    Seems like Krumlink has taken to programming. It's like having control of thousands of little transistors.

    I've sent you a link to google docs with the Mongoose part list in your email.
     
  15. Krumlink

    Krumlink New Member

    Joined:
    Aug 10, 2007
    Messages:
    2,080
    Likes:
    20
    Location:
    Michigan, USA
    So I assume that will be lesson 1a :)

    Bill, who did you send it to? I dont know who you were talking to :)
     
  16. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Krumlink will be quite good at programming. He is a quick study.:)
     
  17. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    Bill,

    Do not recall if anyone has pointed this out.


    1 C1 22uF 16V (must be at least 16V rated)
    is shown as 47 on schematic


    If you used Eagle the BOM, schematic, and board would all be in sync :p
     
  18. Krumlink

    Krumlink New Member

    Joined:
    Aug 10, 2007
    Messages:
    2,080
    Likes:
    20
    Location:
    Michigan, USA
    Ouch!

    I would get 22uf to 47uf, as it appears only to interact with the MOSFET grouping and a diode and the inductor, so it appears to be a coupling capacitor (forgive me if I used the wrong term) between some stuff.

    22 to 47uf would seem acceptable?
     
  19. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    I offer the range of values for anyone building them from their own parts.
     
  20. 3v0

    3v0 Coop Build Coordinator Forum Supporter

    Joined:
    Jul 14, 2006
    Messages:
    9,404
    Likes:
    227
    Location:
    OKLAHOMA USA
    I do not understand, thinking you did understand what I said

    1 C1 22uF 16V (must be at least 16V rated)
    is shown as 47 on schematic
    The parts list state the cap is 22uF and at least 16V
    The schematic says it is 47 and I imagine that means 47uF

    Neither place does it say 22uF-47uF and 22uF != 47uF.
    Maybe both will work but that is not what you have speced.
     
  21. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    Then I'll change it in the document. Bad habit.

    Edit: the Junebug Assembly Instructions have an updated BOM & Schematic.
     
    Last edited: Nov 19, 2007

Share This Page