Read the binary from PORTC pins?

Jacobsen

New Member
How can I'm read the binary from PORTC pins?

Using 2 CMOS type 4516

Picaxe-28x - use PortA

how to convert the value of a byte contents to a 3 decimal ACII code

represenation ?


I Pic-Logicator 2001

I'm do cmd:


----Start
: :
: :
: a=PORT ( Cell Detail- EXPRESSION )
: :
: :
: Serout
: :
:--<---:


How to write this using Basic for PICAXE-28X ??

Would you be kind to give me an example of this function?

regards
Monie
 

MartinM57

Moderator
A few moments in Search for "pinsc" on this forum (hint:always search before asking a question - most things have been done here before) finds:

http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=398&forum_id=3

Binary to 3 character ASCII(untested)...

peek 7, b0
b1 = b0 / 100 + $30
b2 = b0 // 100 / 10 + $30
b3 = b0 // 10 + $30

...but I'll leave you to understand why and learn a bit more about different number systems! (Hint: www.asciitable.com is a good start)

Edited by - MartinM57 on 12/31/2005 11:53:44 AM
 

Jacobsen

New Member
<b> Hello MartinM57 </b>

Will you chek Codes

My code now

Main:

serout 7,T2400,(254,1,255)
pause 30

Loop:

let b0 = pins

peek 7, b0
b1 = b0 / 100 + $30
b2 = b0 // 100 / 10 + $30
b3 = b0 // 10 + $30

serout 7,T2400,(254,128,&quot;Conter: &quot;,#b3,&quot; PORT C&quot;,255)

SERTXD(&quot;Read PORT C: &quot;,#b1,CR,LF)

GOTO Loop

regards
Monie
 

MartinM57

Moderator
Well I doubt that this code does what you want it to do - but why can't you check it yourself? It's not exactly complicated for someone with your experience!

serout 7,T2400,(254,1,255) &lt;-- don't know why you do this - what device is connected?
pause 30 &lt;-- why?

Loop:

let b0 = pins &lt;-- waste of time, next line of code overwrites b0, and you said you wanted to deal with PORTC

peek 7, b0 &lt;-- what i told you
b1 = b0 / 100 + $30 &lt;-- what i told you
b2 = b0 // 100 / 10 + $30 &lt;-- what i told you
b3 = b0 // 10 + $30 &lt;-- what i told you

serout 7,T2400,(254,128,&quot;Conter: &quot;,#b3,&quot; PORT C&quot;,255) &lt;-- why send only the last ASCII digit? - doesn't indicate the value read from PORTC very well

SERTXD(&quot;Read PORT C: &quot;,#b1,CR,LF) &lt;-- likewise, why only the first ASCII character? And what about the second ASCII character

GOTO Loop

...but maybe this code does do exactly what you want it to do - but you haven't indicated what you really want!

Edited by - MartinM57 on 12/31/2005 1:28:46 PM
 

Jacobsen

New Member
Hello everyone, i am tring to read Read the Number from all PORTC Digital input.

With 50 Hz input to Cmos 4516 wired op to 4 leds, all 4 led turned on.

and is showing these bits:
8 bit
4 bit
2 bit
1 bit

This gives 1 + 2 + 4 + 8 = <b> 15 bit </b>

The 15 bit I want displayed with Cmd: serout 7,T2400,(254,128,&quot;Read Number: &quot;,#b4)
How can that we done?
&quot;MartinM57&quot;s code proposals, give these display readouts:

Bit Ialt: 52
Bit Ialt: 56
Bit Ialt: 48
Bit Ialt: 50
Bit Ialt: 56
Bit Ialt: 52
Bit Ialt: 48
Bit Ialt: 52
Bit Ialt: 56
Bit Ialt: 48
Bit Ialt: 50
Bit Ialt: 56
Bit Ialt: 52
Bit Ialt: 48
Bit Ialt: 52
Bit Ialt: 57
Bit Ialt: 48
Bit Ialt: 50

My code:

<code><pre><font size=2>

Main:

Init:
Serout 7,T2400,(254,1) 'Clear LCD
Pause 30
Loop:
Peek 7, b0
Let b0 = b0 * 100

B1 = b0 ???? 'Thousands ??
B2 = b0 / 100 + $30 'Hundreds
B3 = b0 // 100 / 10 + $30 'Tens
B4 = b0 // 10 + $30 'Units

Serout 7,T2400,(254,128,&quot;Read Number: &quot;,#b4)

SERTXD(&quot;Read Number: &quot;,#b4,CR,LF)

GOTO Loop

&lt;/font&gt;&lt;/pre&gt;&lt;/code&gt;

I have looked in PICAXE Forum for sampels with no luck.

With 50 Hz input to Cmos 4516, and with 4 outputs ON, I still can't 15 shown in the display


How do I convert the value of a byte contents to a 4 decimal ACII code

I hope you can help me ?

<b> Happy New Year! </b>


regards
Monie


Edited by - Monie on 1/1/2006 12:24:30 PM </font></pre></code>
 

MartinM57

Moderator
I'm sorry Monie, but your basic understanding is completely wrong. You really need to understand a number of things before going forward with this application.

Here's some things you need to understand:
1. 4516 is a full 4-bit binary counter (maybe you really want to use 4510 0-9 counter, but let's assume you really do want 4516). If you send it a 50Hz clock, the Qx outputs will change at every clock pulse to show a normal count sequence:
0000 = decimal 0
0001 = decimal 1
0010 = decimal 2
etc etc
1101 = decimal 14
1111 = decimal 15
0000 = decimal 0
etc etc

2. But of course, no combination of Qx outputs is constant for more than 1/50 second since the next clock pulse changes them.

3. So if you hook up LEDs to the Qx outputs it will look like they are all on all the time - but of course they aren't, they're just flashing really fast. Try changing the clock to 1HZ and then you would see them counting.

4. Then I assume you have connected one 4516 to PORTC (you talk about 2x 4516, then 1, so I'm not sure), let's says inc0, inc1, inc2 and inc3. Let' assume you ground inc4, to inc7.

5. You then set up a fast loop to read the value from PORTC. Each time you read PORTC it will have a different value, since the Qx outputs are changing 50 times per second.

6. You then want to output the value to an LCD. You originally asked how to convert byte to 3 ASCII digits and I told you. But of course there is no need for this at all - serout and sertxd do this for you themselves.

(by the way, your attempts to introduce a 'thousands' ASCII character are completely wrong - and you will never get a 'thousands' digit anyway, since the maximum value of PORTC is 255 when each pin is at logic one)

7. So all I think you need to code is (untested):

Serout 7,T2400,(254,1) 'Clear LCD
Pause 30

Loop:
Peek 7, b0

Serout 7,T2400,(254,128,&quot;Read Number: &quot;,#b0)

SERTXD(&quot;Read Number: &quot;,#b0,CR,LF)

GOTO Loop

8. Of course, with a 50Hz clock into your 4516, you will still get, effectively, random numbers displayed on the LCD all the time. Again, set your 4516 clock to 1Hz, and you will have a chance at seeing the numbers 0 to 15 being displayed on the LCD....

I'm done with typing for now, so Happy New Year to you, Monie, and good luck with all your future PICAXE projects in 2006 and beyond....Martin
 

Jacobsen

New Member
How can I&#8217;m read digital output only leg 11 ??
Uses PICAXE-28x

Serout 7,T2400,(254,128,&quot;Read leg 11: &quot;,#b0)

Here's some things I&#8217;m illustrate untested.

The binary number when converted into decimal:

<code><pre><font size=2>

1 x 128 = 128
0 x 64 = 0
0 x 32 = 0
1 x 16 = 16
0 x 8 = 0
1 x 4 = 4
1 x 2 = 2
1 x 1 = 1


<b> Total: 151 </b>

Serout 7,T2400,(254,128,&quot; Total: &quot;,#b0)

</font></pre></code>

<b> Best regards </b>

Monie
 

Jacobsen

New Member
Hello all, I'm having trouble and frustrations with the PORTC

How can I&#8217;m read digital output only eksempel leg 11 - read ON / OFF from Digital input??
Would you be kind to give me an example of this function?

Serout 7,T2400,(254,128,&quot;Read leg 11: &quot;,#b0)

Show hir schematic

Astabil multivibator:
<A href='http:// www.sunwind.dk/astabil_multivibrator.jpg ' Target=_Blank>External Web Link</a>

I's 8 Bit Convert:
<A href='http:// www.sunwind.dk/convert.jpg ' Target=_Blank>External Web Link</a>
Input-Puls into Cmos 4516 U1 and U2 (2x leg 15)

Here's some things I&#8217;m illustrate untested.

Outpt from convert U3 and U4 leg (2x) 6,11,14 and 2

The (8 bit) binary number when converted into decimal:

<code><pre><font size=2>

1 x 128 = 128
0 x 64 = 0
0 x 32 = 0
1 x 16 = 16
0 x 8 = 0
1 x 4 = 4
1 x 2 = 2
1 x 1 = 1

<b> Total: 151 </b>


Serout 7,T2400,(254,128,&quot; Total: &quot;,#b0)

&lt;/font&gt;&lt;/pre&gt;&lt;/code&gt;

please can you give me an example of this function?

I would be very pleased if you would help me to solve the problem.

<b> Best regards </b>

Monie


Edited by - Monie on 1/4/2006 8:42:17 AM &lt;/font&gt;&lt;/pre&gt;&lt;/code&gt;

Edited by - Monie on 1/4/2006 8:44:42 AM </font></pre></code>
 

Jacobsen

New Member
How can I&#8217;m read digital output only eksempel leg 11 - read ON / OFF from Digital input??
Would you be kind to give me an example of this function?

Experiment code:
<code><pre><font size=2>
Main:

init:
serout 7,T2400,(254,1) 'clear LCD
pause 30
Loop:
Peek 7, b0

'setint %00000001,%00000001 'will check input pin 0
'%00000010 will check input pin 1
'%00000100 will check input pin 2
'%00001000 will check input pin 3
'%00010000 will check input pin 4
'%00100000 will check input pin 5
'%01000000 will check input pin 6
'%10000000 will check input pin 7

Serout 7,T2400,(254,128,&quot;Read Number: &quot;,#b0)

SERTXD(&quot;Read Number: &quot;,#b0,CR,LF)
GOTO Loop
</font></pre></code>

Best regards
Monie


Edited by - Monie on 1/4/2006 10:28:41 AM
 

BeanieBots

Moderator
If we are talking about the 28X, then physical pin 11 is input 0.
This can be tested by:-

if pin0=X then ... (where X can be 0 or 1)

or assign to variable

b0=pin0 '(b0 will then be 0 or 1 depending on the logic level applied to physical pin 11)

If you want to drive physical pin 11 as an output, then use the portc command.

High portc 0 'will make physical pin 11 go high.

I have never tried mixing the use between input and output in the same program. You might have to state that it is an input again before reading in a value if you have set it as an output.

Hope this helps.
 

Jacobsen

New Member
<b> Hello BeanieBots </b>

I's 8 Bit Convert:
http://www.sunwind.dk/convert.jpg

Ouputted from 4516 U3 and U4 (2x leg 6,11,14 and 2)

When I manually set the digital (pin0) input high (+5V) I can get a
reading with the basic code below, but it doesn't work when the output
from 4516 is connected to the digtial inputs
It is as if the outputs are on or off 1/50 of the time as &quot;MartinM57&quot;
points out in a previous post

<code><pre><font size=2>

Main:

init:
serout 7,T2400,(254,1) 'clear LCD
pause 30
Loop:

b0=pin0

if pin0=1 then testON
if pin0=0 then testOFF

testON:
b0 = 4
goto forset

testOFF:
b0 = 0
goto forset

forset:

Serout 7,T2400,(254,128,&quot;Read Number: &quot;,#b0)

SERTXD(&quot;Read Number: &quot;,#b0,CR,LF)

GOTO Loop

</font></pre></code>


Does anyone know what Cmos circuit I can put infront of the 2x4516 (8
outputs), that is binary to decimal / analog output?

Best regards
Monie
 

BeanieBots

Moderator
OK, let's get back to basics.
Are you trying to read an 8-bit value that is connected to 8 inputs on a PICAXE 28X?

If yes, then use:-
b0=pins 'b0 now has the number.

What is your circuit supposed to do?
Converting the output to something else will be a complete waste of time and effort if the output is not what you expect in the first place. Besides, if you can read it with the PICAXE then do the conversion in the PICAXE.
 
Top