Author Topic: WebCat and DIO with tags  (Read 11991 times)

hawui1

  • Guest
WebCat and DIO with tags
« on: January 12, 2007, 05:04:12 am »
Hi,
I recently bought a DIO card that I plugged into my MINI-MAX/51-E + MMC+RTC "castle" of boards.

I wanted to communicate with this I2C card by using embedded and remote tags in WebCat pages. Is it possible ?

For example how can I set the first open collector output or how can I assign/display the status of this output ?

Thanks in advance for your time.
Ciao !

vitaliy

  • Full Member
  • ***
  • Posts: 30
    • View Profile
Re: WebCat and DIO with tags
« Reply #1 on: January 12, 2007, 12:44:24 pm »
<form method="get" action="dio.asp" name="">
<input name="I2CSTART" type="hidden" id="I2CSTART">
<input name="I2CNUM" type="hidden" id="I2CNUM" value="16">
<input name="I2CNUM" type="hidden" id="I2CNUM" value="2">
<input name="I2CNUM" type="hidden" id="I2CNUM" value="255">
<input name="I2CSTOP" type="hidden" id="I2CSTOP">
<input type="submit" name="Submit" value="Set Outputs">
</form>

There are brief explanations of "Set Outputs" action

Start
Write 16 // DIO I2C address
Write 2 // PORTB UNIT
Write 255 // PORTB = 255
STOP
....

<form method="get" action="dio.asp" name="">
<input name="I2CSTART" type="hidden" id="I2CSTART">
<input name="I2CNUM" type="hidden" id="I2CNUM" value="16">
<input name="I2CNUM" type="hidden" id="I2CNUM" value="2">
<input name="I2CNUM" type="hidden" id="I2CNUM" value="0">
<input name="I2CSTOP" type="hidden" id="I2CSTOP">
<input type="submit" name="Submit" value="Clear Outputs">
</form>

There are brief explanations of "Clear Outputs" action
Start
Write 16 // DIO I2C address
Write 2 // PORTB UNIT
Write 0 // PORTB = 0
STOP


Please download DIO technical manual from www.bipom.com

Also, please look at examples of 8051/52 development system under
C:\\bipom\\devtools\\MicroC\\Examples\\8051\\tiny\\IO_Expander
to obtain more information on UNITS of DIO board




hawui1

  • Guest
Re: WebCat and DIO with tags
« Reply #2 on: January 12, 2007, 02:50:03 pm »
It worked perfectly ! Thankyou ! ;-)

The only thing that is still missing is how to read the input/output ports tied to the connectors X2 and X3..
If you could help me with this last step I would appreciate it very much.

Thanks again vitaliy

vitaliy

  • Full Member
  • ***
  • Posts: 30
    • View Profile
Re: WebCat and DIO with tags
« Reply #3 on: January 12, 2007, 03:18:56 pm »
<form method="get" action="dio.asp">
<input type="hidden" name="I2CSTART">
<input type="hidden" name="I2CNUM" value="16">
<input type="hidden" name="I2CNUM" value="0">
<input type="hidden" name="I2CSTART">
<input type="hidden" name="I2CNUM" value="17">
<input type="hidden" name="I2CREC">
<input type="hidden" name="I2CNAK">
<input type="hidden" name="I2CSTOP">
</form>
^I2CNUM^

Start
Write 16 // DIO I2C address
Write 0 // PORTA UNIT
Start
Write 17 // DIO I2C address | READ
Read      // Read port A to internal buffer
Nak
STOP

WebCat server will replace ^I2CNUM^ with the received data byte from the internal buffer

Also, you can empty the internal buffer using the following form

<form method="get" action="dio.asp">
<input type="submit" name="CLR" value="IP - clear RX buffer of I2C Port">
<input type="submit" name="CLR" value="IB - reset TAG pointer of I2C buffer">
</form>




« Last Edit: January 12, 2007, 03:20:34 pm by vitaliy »

hawui1

  • Guest
Re: WebCat and DIO with tags
« Reply #4 on: January 13, 2007, 02:15:32 pm »
Hi Vitaliy,

I tested the code you supplied,
I just added a

<input type="submit" name="Submit" value="Read Inputs">

in the first form (the one to read ^I2CNUM^) and, at a first glance it appeared to be working, infact it was returning a value of 63 in ^I2CNUM^..
Placing the first pin (RA0 on X2) to ground though a 1.2K resistor was changing the value to 62 (63-2^0), if the resistor was tied to RA1 on X2 instead the value was 61 (63-2^1) ..so everything ok.. but, after eight times I was interrogating the value submitting the same form, the returned value started to be 0 and remained stuck to 0 at all times, even if I continued to interrogate it and the ports were left unconnected.. I removed the power supply, tried again and doh! again 63.. I left the input ports unconnected and again after eight queries the returned value remained then stuck at 0 ...
It looks like after eight queries a buffer is filled and the read cannot be performed anymore..
I Tried also to reset the buffer with the code you supplied when the query starts to give back 0 but with no success..

Where am I making the mistake ?

This is the code I used

One page named dioread.asp
-------------------------------------
<body>

<form method="get" action="dioread.asp">
<input type="hidden" name="I2CSTART">
<input type="hidden" name="I2CNUM" value="16">
<input type="hidden" name="I2CNUM" value="0">
<input type="hidden" name="I2CSTART">
<input type="hidden" name="I2CNUM" value="17">
<input type="hidden" name="I2CREC">
<input type="hidden" name="I2CNAK">
<input type="hidden" name="I2CSTOP">
<input type="submit" name="Submit" value="Read Inputs">
</form>
^I2CNUM^

</body>
--------------------------------------

One page named dioreset.asp
---------------------------------------
<body>

<form method="get" action="dioreset.asp">
<input type="submit" name="CLR" value="IP - clear RX buffer of I2C Port">
<input type="submit" name="CLR" value="IB - reset TAG pointer of I2C buffer">
</form>

</body>
---------------------------------------


hawui1

  • Guest
Re: WebCat and DIO with tags
« Reply #5 on: January 14, 2007, 03:23:42 am »
Ok, I did some testing, it works but I\'m not sure whether I\'m doing it correctly or not..

in particular

--------------
<form method="get" action="dioread.asp">
<input type="hidden" name="I2CSTART">
<input type="hidden" name="I2CNUM" value="16">
<input type="hidden" name="I2CNUM" value="1">
<input type="hidden" name="I2CNUM" value="255">
<input type="hidden" name="I2CSTOP">
<input type="submit" name="Submit" value="Set Inputs">
</form>
------------------

The above should set all the lines of Port A as inputs by writing 255 (0xFF) to TRISA register right?

The following instead should clear both the pointer and the data in the I2C receive buffer, so this has to be performed BEFORE reading the value of the bitmask of the PORT A inputs

---------------------
<form method="get" action="dioread.asp">
<input type="hidden" name="CLR" value="IP">
<input type="hidden" name="CLR" value="IB">
<input type="submit" name="Submit" value="Clear Buffer">
</form>
-----------------------

Then I read the actual bitmask of the PORT A inputs
----------------------
<form method="get" action="dioread.asp">
<input type="hidden" name="I2CSTART">
<input type="hidden" name="I2CNUM" value="16">
<input type="hidden" name="I2CNUM" value="0">
<input type="hidden" name="I2CSTART">
<input type="hidden" name="I2CNUM" value="17">
<input type="hidden" name="I2CREC">
<input type="hidden" name="I2CNAK">
<input type="hidden" name="I2CSTOP">
<input type="submit" name="Submit" value="Read Inputs">
</form>
^I2CNUM^
---------------------------

Is all of this correct ?
« Last Edit: January 14, 2007, 03:25:42 am by hawui1 »

vitaliy

  • Full Member
  • ***
  • Posts: 30
    • View Profile
Re: WebCat and DIO with tags
« Reply #6 on: January 14, 2007, 03:32:12 am »
> Found a possible solution.. let me know if it\'s correct
yes, it\'s correct.
It is necessary to empty I2C buffer periodically.
The buffer has only 8-byte depth.

Also, you can reset the I2c Pointer only (CLR=IP).
This way you can re-get all the bytes from buffer again.

> Question :  
> How can I explicitly set some lines as inputs and some > as outputs in port A ?

You can do that using TRISA unit.

#define PORTA_UNIT                        0
#define TRISA_UNIT                        1
#define PORTB_UNIT                        2
#define TRISB_UNIT                        3
#define PORTC_UNIT                        4
#define TRISC_UNIT                        5


For example, you would like to have 3 inputs( PORTA0..2) and 3 outputs (PORTA3..5).
It means you have to write 7 (000111B) to TRISA.
1 defines  input
0 defines output

hawui1

  • Guest
Re: WebCat and DIO with tags
« Reply #7 on: January 14, 2007, 04:24:10 am »
Perfect ! Thanks a bunch one more time ;-)

biffvomicona

  • Guest
WebCat and DIO with tags
« Reply #8 on: December 07, 2011, 12:07:10 am »
Yea, agree with Maverick, put an option where you both can disable it and set the delay.
Also, Im really not a newbie but I find this option really useful. It can speed up the work.