PDA

View Full Version : Custom array of pins



bmagistro
- 21st March 2009, 23:54
Hello,

I'm hoping someone can point me in the right direction, I want to create an array of pins something like what is shown below, but I haven't found a way yet. Thanks in advance guys.



myvar[0] = portb.2
myvar[1] = portc.1
myvar[2] = portc.5

Archangel
- 22nd March 2009, 00:22
Hello,

I'm hoping someone can point me in the right direction, I want to create an array of pins something like what is shown below, but I haven't found a way yet. Thanks in advance guys.



myvar[0] = portb.2
myvar[1] = portc.1
myvar[2] = portc.5

Hi bgmagistro,
I would submit, that you have !


MyPort var byte 'your new ports name
myport.0 = portB.0 'seg. A
Myport.1 = PortA.0 'seg. B
Myport.2 = PortB.1 'seg. C
Myport.3 = PortB.2 'seg. D
MyPort.4 = PortA.1 'seg. E
Myport.5 = PortA.2 'seg. F
MyPort.6 = PortB.3 'seg. G
MyPort.7 = PortB.4 'dec point
num var byte 'where your display pattern gets put
index var byte 'where your number originates
lookup2 index,[%11111000, %01100000,%11011010],myport ' just 0,1,2 in this short table
'myport = num 'display pattern loads into ports for display
'you may eliminate the last statement, put myport instead of num
main: 'do something here

victorf57
- 22nd March 2009, 00:24
Do you mean something like this?

myvar1 var portb.1
myvar2 var portc.3

Victor

bmagistro
- 22nd March 2009, 02:17
i'm looking for something closer to what joe s. has so that i can run some code in a loop and have it change if those pins are high or low without having to have a separate if statement for each pin.

thanks again in advance

paul borgmeier
- 22nd March 2009, 04:42
this might help
http://www.picbasic.co.uk/forum/showthread.php?t=4074

bmagistro
- 22nd March 2009, 14:07
thanks for the reply that was exactly what i was looking for. I am basing my code off of this post http://www.picbasic.co.uk/forum/showpost.php?p=22012&postcount=11. thanks again

bmagistro
- 22nd March 2009, 15:59
Would you happen to know how the offset works as mentioned in the previous post? I ran in to some problems with that block of code and think it has to do with finding and setting the offsets of the pins. I am working with a pic18f24k20 if that makes a difference.

paul borgmeier
- 26th March 2009, 06:55
I am not familiar with the pic18f24k20 nor does my version of PBP support it.

Perhaps someone else knows the order of the ports for this PIC. I could not readily put my hands on the datasheet - it would not download from microchip for me?

Darrel Taylor
- 26th March 2009, 19:33
Would you happen to know how the offset works as mentioned in the previous post?

Bruce's thread might help with that.
Indexing Port Pins
http://www.picbasic.co.uk/forum/showthread.php?t=3753

Depending on what you're doing, you might have better luck with post #14 in the thread Paul mentioned.
http://www.picbasic.co.uk/forum/showthread.php?p=22039#post22039

bmagistro
- 28th March 2009, 23:15
thanks guys for all your help. i found my problem(s), simple counting error and typo in the code.