Continue to Site

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.

  • 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.

18F1320 Junebug and Swordfish question.

Status
Not open for further replies.

tallan

New Member
Hello everyone,

Well I haven't had to much time to play but I am playing. :)

Anyway I had thought I would have picked this up a little quicker but at least I think I am starting to get it.

So just playing around for the most part I modified Bill's demo swordfish program a little. Instead of going one way it now goes back and forth.

I am sure their is a better way to do this but I haven't figured it out yet so please feel free to drop me clues, by the way I'm pretty dense. :D


Code:
 // Name : BLINK_1.BAS
Device = 18F1320
Clock = 4            // 4MHz clock
Include "junebug.bas"
Dim Count As Byte
OSCCON = $62         // select 4MHz internal clock
ADCON1 = %11110101   // digital I/O except RA1 & RA3
While True
    Count = 1
        While Count < 6
            LED(Count)   // light LED(1..6) or none LED(0)
            DelayMS(100) // delay in 1000s of a second
            inc(Count)
        Wend   
   
        While Count > 1
                LED(Count)   // light LED(1..6) or none LED(0)
                DelayMS(100) // delay in 1000s of a second
                dec(Count)
        Wend
Wend
End

My next step is an adjustable chase rate using VR1 on the Junebug however I'm still learning and not quite sure where to look for that information. So if you could point me to where I can gain that knowledge I would be most grateful!

Thanks in advance and please feel free to let me know where I may be able to clean the posted code up a bit as well so I can be more effective.

Ted
 
I've not got my Junebug setup at the moment, I'm on the road. But for info on using the A/D check JPUG#2 there is a 4 channel A/D program. I'll look at the thread again when I get home in a few hours.

Now to get fancy VR1 could control L-R and VR2 R-L
 
Last edited:
Thought I'd have a play with this.

If you want to have a go at doing this yourself then stop reading now.

Code:
// Name : BLINK_1.BAS
Device = 18F1320
Clock = 4            // 4MHz clock
Include "junebug.bas"
Dim Count As Byte
dim GO as ADCON0.1
OSCCON = $62         // select 4MHz internal clock
ADCON1 = %11110101   // digital I/O except RA1 & RA3
ADCON0 = %00000101   //A2D on and select AN1
ADCON2 = %00110101   //Left justify - Fosc/16
While True
    Count = 1
    While Count < 6
        GO = 1              //start conversion
        While(Go=1)         //wait for it to complete
        Wend   
        LED(Count)          // light LED(1..6) or none LED(0)
        DelayMS(ADRESH+10)  // delay in 1000s of a second
        Inc(Count)
    Wend   
    While Count > 1
        GO = 1              //start conversion
        While(Go=1)         //wait for it to complete
        Wend   
        LED(Count)          // light LED(1..6) or none LED(0)
        DelayMS(ADRESH+10)  // delay in 1000s of a second
        Dec(Count)
    Wend
Wend
End

Mike.
 
Last edited:
Hey Pommie,

Well I had to look, thanks for doing that though because I just spent the last 45 Minutes understanding what you did. :) Section 17 of the datasheet. :D

So if I wanted to move this to a circuit I guess I would have to rewrite the junebug mod a little if I were NOT going to include charlie-plexed LED's and go to a on off configuration huh. Well I guess I can play with that now and see. :)

Bill,

Thanks again, I knew I saw that somewhere. Any other Jpugs coming out soon?

Ted
 
Last edited:
Hello Everyone,

Well I'm having some issues setting some of the pins to output.

I wrote a custom module pretty much based on the junebug one without the multiplexing of the leds though, it is going straight to output now

ie
LED 2 //this is LED Out - RA1 and RA3 because they are A to D
High(PORTA.2)


Anyway I seem to hit a few pins that won't go to output, It's mostly the PORTB pins like PORTB.2 and PORTB.3

Any Idea's as to what I am overlooking?

Thanks Everyone.

Ted
 
Port RB2 on the tutor should not be assigned as an input as connects to a pushbutton. RB3 should work fine as an output, it uses CON5 and can be made an input or output.
What does the program look like? Are you using the tutor or an external 18F PIC?
 
Hey Bill,

Yeah I am using the ID2 cable to a test board and using a separate 18F1320.

The code itself is what Pommie posted however the module I am loading is based off the first part of your Junebug.bas module but I am not setting one port high and one low because I don't plan on multiplexing any LED's.

From memory it's like this
Code:
Mymod.bas

CASE 1  // Out 1
High(PORTA.0)

CASE 2 / Out 2
TRISTA.0 = 1    // Did this to get the first light off and all outs below as well
High(PORTA.2)  // Used 2 because 1 and 3 were for A to D conversion

ELSE               // All Off
TRISA.0 =1
TRISA.2 = 1

I hope to have an 8 - 10 channel chase that I will then opto to a triac so I can run some 120V Christmas animations I created.

Anyway, the PORTB does not seem to go high for some reason, ADCON1 I thought set all the pins to Digital (PORTA and PORTB) so I am wondering if it is just doing the PORTA pins?

Anyway thanks again for all your help, I am learning more then I had ever thought.

Ted
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top