Page 1 of 1

12 switch to 12 LED

Posted: Tue Mar 20, 2012 11:52 am
by christoph
Hi all,

Desparate now!! All my hardware and sensors are ready but not been able to get electronics working for 12 ways.

PIC16F88, 12 switch Tx, then via UART (hardwired & wireless), to 12 LED Rx box. Effectively 12 clean contact sensors to 1 receiver with 12 LEDs, to indicate the continual status of the switches.

Despite very willing help from the forum - which is really appreciated - I can only get a 6-way system to actually work (and it works perfectly - hardwired or over a radio link).

Has anyone done this already and could post appropriate flowcharts for me to try?

Thanks in advance for any input that might help,

Chris

Re: 12 switch to 12 LED

Posted: Tue Mar 20, 2012 12:51 pm
by Benj
Hi Chris,

Looking at your old program it shouldn't be too hard to store 12 individual bits.

You will have to use 2 byte variables to store your data.

The first 8 will use byte 1 and the second 4 will use byte 2.

Then you simply the data into and out of the byte like this.

populate the byte

byte1 = 0
byte1 = byte1 | (data0)
byte1 = byte1 | (data1 << 1)
byte1 = byte1 | (data2 << 2)
byte1 = byte1 | (data3 << 3)
byte1 = byte1 | (data4 << 4)
byte1 = byte1 | (data5 << 5)
byte1 = byte1 | (data6 << 6)
byte1 = byte1 | (data7 << 7)

byte2 = 0
byte2 = byte2 | (data8)
byte2 = byte2 | (data9 << 1)
byte2 = byte2 | (data10 << 2)
byte2 = byte2 | (data11 << 3)

Hope this helps.

Re: 12 switch to 12 LED - help

Posted: Tue Mar 20, 2012 5:30 pm
by christoph
Sorry Benj, thought I was getting the hang of things but I really not sure how to implement the information you posted - could you give me a bit more help to get this going for Tx and Rx - I've spent about 6 hours or more trying yesterday and today (and the past couple of weeks trying to do it myself - I'm obviously getting too old for this stuff) but I'm getting nowhere and I would like to at least complete this project!

Would really appreciate, many thanks,

Chris

Re: 12 switch to 12 LED

Posted: Thu Mar 22, 2012 1:36 pm
by Benj
Hi Chris,

What about attaching the program you have so far so we can try and spot what your doing wrong and steer you in the right direction.

Re: 12 switch to 12 LED

Posted: Fri Mar 23, 2012 5:04 am
by christoph
Hi Benj
thanks for the reply - please see the attachments which I am trying to get working and based on the last information you posted but as I said, I'm not sure whether I am implementing it properly - well obviously not I guess! Would be great if you can see what I am doing wrong.

I am not using any of the e-blocks by the way.

I have not used A2, A5, B2 and B5 to avoid complications as you will realise and I have nothing else connected apart from the necessary pull up/down resistors particularly the 10k pull ups on A5/MCLR.

Be great if I could get this sorted over the weekend and I do appreciate your help.

Best regards,

Chris

Re: 12 switch to 12 LED

Posted: Fri Mar 23, 2012 12:53 pm
by Benj
Hi Chris,

Here is a set of progs that should work. I have simplified it a lot and hopefully this should be very reliable on the hardware.

Re: 12 switch to 12 LED

Posted: Sat Mar 24, 2012 1:56 am
by christoph
Hi Benj,

Many thanks for your positive response and looking forward to checking them out but unfortunately I am getting the following 2 messages when I try to open the flowcharts:

"The file you are loading was made by a newer version of FlowCode (42>31) and may not load correctly. Do you wish to continue loading it YES / No"

On replying 'YES' :

"Unable to create microcontroller pic8 as the definition file pic8.FCD is missing or corrupt. [ 0x200]"

I then checked 'Updates' and it confirms my current version is 4.5 and is up to date!

Regards,

Chris

Re: 12 switch to 12 LED

Posted: Sat Mar 24, 2012 10:18 am
by JohnCrow
Hi Christoph

Looks like the programs Benj posted are in FC5.
Ive not been able to open them with FC 4.5.18.74, but do open with in FC5

Re: 12 switch to 12 LED

Posted: Sat Mar 24, 2012 11:40 am
by DavidA
Hi chris,

You can download the free v5 and you should be able to view the flowchart, you wont be able to compile to chip but i dont think thats what you want from it.

Re: 12 switch to 12 LED

Posted: Sat Mar 24, 2012 11:51 am
by medelec35
Hi Chris,

David's got a very good point,
but I starting the conversion before his post.
So Im going to carry on and post the V4 version of Ben's modifications.
But It's still very worth while downloading the free version of V5 to have a play, since there is a vast difference between V4 and V5
Free version can be found here:
http://www.matrixmultimedia.com/lc_index.php?p=25



I did notice that RX version you posted was not configured at all.



Martin

Re: 12 switch to 12 LED

Posted: Sat Mar 24, 2012 1:16 pm
by christoph
Hi all....

BRILLIANT - It all works a TREAT - I am 'over the moon' - special thanks to Benj, John, David and Martin for sparing the time to get this going against all the odds with my lack of experience with both programming and micro controllers in general. I really appreciate all your help.

Martin, thanks for the conversion which as I happened to be here, meant that I could immediately try it out. The flowcharts I posted which were not configured were - I think - because I made a change because they didnt work, saved it but then realised it was a silly change and changed it back and posted straight away without configuring.

Cheers everyone - have as great a day as I am having!!

Best regards,

Chris