Electronics PICs, Luxeons, PWM ...n00b in need of some advice!

Discussion in 'Modding' started by H2O-G33K, 11 Apr 2004.

  1. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    H2O-G33K: How many I/O's do you actually need for this project?
     
  2. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    As well as the three PWM channels? Er, not many really - I'd like a button or two to switch between different light shows, but that's all.

    The luxeons are something to think/worry about later I reckon - for now, just regular super-bright LEDs would be great!
     
  3. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    I found the graph someone mentioned earlier :

    [​IMG]

    So it looks like I could get away with 10Mhz = 2.5Mhz instruction cycle? ...or run at 20MHz = 5Mhz instruction cycle, but for less time (batteries will reach a critical limit sooner).. ?

    Something's been bugging me about using resisitors. Surely if you use resistors to limit the current, at full charge everything's fine, but as the charge in the batteries drop, won't the LEDs dim? If you switched to a lower rated resistor, you could get them back to full brightness again though? That right or have I over-simplified / got it wrong? :confused:
     
    Last edited: 22 May 2004
  4. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    I've been thinking again, and to make life much easier on myself, I'm thinking hardware PWM is probably the way forward (and yes, I know I keep changing my mind all over the shop :) ).

    The PIC16F73 seems to have 3 PWM channels, although I couldn't figure out from the datasheet how you set it up? ...and for that matter what the resolution is? It looked like 6-10 bits depending on how fast your PWM signal is. Does that mean I could achieve 6-10 different light levels? :confused:

    I need some more help here :(
     
  5. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf

    should tell you, i've not got time to read it i'm affriad (exam tommorow, and day after,and day after,and day after, all through to (and including) sat. barstards).

    but from memory i thought it was a 3 channel CCP, but only 2 channel pwm.
     
  6. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    Damn, you're right. I wanted the 737 chip, which does have 3 PWM channels.. problem is, farnell doesn't stock them! Where else might I find PICs in the UK?
     
  7. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
  8. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    Okay, okay I get the picture.. Those were the sites I'd been looking at, just wondered if you knew of any more :)

    Looking at the datasheets, the normal (not LF) version will run at 40Mhz as long as it's supply is > 4.2v. The LF version does the same, but the speeds then ramp down as low as 2v. A friend of mine who's a little more electronic-savvy suggested using a DC-DC converter to make sure the voltage always stays high enough for the controller to run. What are your thoughts on this?

    From what I can gather from the datasheets, you need an external oscillator to get the high frequencies.. So, what sort of oscillator would you recommend?

    Thanks for all the help thus far - much appreciated. :D

    P.s - good luck with your exams! I have my last one on Friday :clap:
     
    Last edited: 23 May 2004
  9. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    Oooh... update : My PIC-PG2C arrived in the post today! :clap:

    I have some 18F1320's in the post so maybe I can start trying some stuff soon :)
     
  10. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    Finally got around to playing with a PIC tonight. I don't have time to test it tonight, but I hacked one of Hazer's tutorials up a little so that my PIC will strobe the lowest bit of port A on / off every 0.5s. If what I've done works, I'll try speeding up the strobing at faster speeds until you can't see the strobing whilst it's being swung around. More than likely thought, this won't work the first time.. keep your fingers crossed please! ;)
     
  11. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    PICs + LEDs are fun!

    I've been playing with a little project for writing msgs using just persistance of vision lately, quite cool, so far i can write Animus nicely, only problem is i want the chip to do the maths to determine how fast your waving it on the fly using the cheapest possible tilt sensor!

    I found that getting a dim colour when the LED is been moved at high speed very challenging (heck i gave up, and put in 3 levels of resistors!).
    I am still trying to think of a more elegant solution (one was using the built in pull up resistors!) when i do i will let ya know!
     
  12. Mark R

    Mark R What's a Dremel?

    Joined:
    29 May 2002
    Posts:
    158
    Likes Received:
    2
    I have got, somewhere, a full software 3 channel 8 bit PWM code for PIC16.

    If anyone is interested, I'll see if I can dig it out, but I'll warn you that it's a right mess and eats up about 75% of CPU cycles.
     
  13. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    Sounds interesting.. what frequency does it's output run at? That's the real limiting factor in this application. It's going to have to be a pretty high value.. at least that's what I reckon ;)

    From a previous post of mine :

     
  14. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    I think i posted in this thread earlyer the easyest way of getting 8-bit PWM from software for as many pins as you like, but it assumes you have a spare timer interupt.

    you just test the value of the TMR set to auto increment, test against a value for your pin, if it overflows, set that pin high.

    so its like
    CLRF PORTATMP
    MOVLW 0x80 ; on half the time
    ADDWF TMR0, W
    BTFSC STATUS, C
    BSF PORTATMP, 1
    MOVF PORTATMP, W
    MOVWF PORTA

    if you want the pin to be on 1inFF times, then just make it 1! and so forth.

    8 bit, very nice, but oh dear, only 8 distinct values.

    I've got some code which i will dig out later today (hopefully) that allows you to control this software PWM via the comm port, also got a VB app that lets you use a scroll bar to choose the luminosity. But its somewhere on the archive computer.
     
  15. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    Post #27 :)
     
  16. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    wasn't quite so sloppy in that one either! :lol:
     
  17. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    Right, it seems my assembly skills are lacking. I've set up as much as I can see is necessary, but I'm not seeing the blinking LED I was expecting.

    I'm using a PIC18F1320. I've tried to set the thing up to use the 8MHz internal oscilator. Here's my ASM file / workspace (hacked from one of hazer's tutorials) :

    hyperlight.zip

    And here's the config :

    [​IMG]

    I thought that it ought to switch on / off an LED on RA0 every 0.5s. As for my circuit, I'm running 5v into pin 14 (Vdd/AVdd) and gnd to pin 5 (Vss/AVss). I've got the LED connected to RA0 via a current limiting resistor.

    I've no doubt missed something, so what d'you suppose it is?
     
  18. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    watchdog timer, or MCLR?
     
  19. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    MCLR is ok, but the watchdog timer needs turning off.
     
  20. H2O-G33K

    H2O-G33K What's a Dremel?

    Joined:
    25 Jan 2003
    Posts:
    240
    Likes Received:
    0
    That got it - thanks guys..
     

Share This Page