Outputs work fine, my mistake was in casting the registers to
unsigned int rather than an 8 bit unsigned char.
I didn't use a voltmeter but my LEDs and Servo began to twitch.
FYI, the 2 74HC04 hex invertors (one at 3.3 and the other at 5.5)
worked well as a buffer. I'll test it for inputs later and let you
know.
A snippet from the datasheet:
An input protection circuit ensures that 0V to 7V can be
applied to the input pins without regard to the supply voltage.
This device can be used to interface 5V to 3V systems
and two supply systems such as battery back up.
The other device, TI SN74LVC8T245 looks like it can do the
job in an SMT kinda way. And then there is always the photo
coupler.
--- In "Don W. Carr" <> wrote:
>
> I did not have a volt meter to test the code for discrete outputs,
but
> it should work. My code for the timer is correct using 0x40 and
0x00
> for the first two registers, but I am now about to test on the TS-
7300
> with two TS-XDIOs. I think Jessie will be discussing other issues
with
> the counter input on the TS-XDIO.
>
> You should probably also make sure interrupts are off with:
*xdio_r3 = 0x00;
>
> Then write to register 2 to send the outputs. For example:
*xdio_r2
> = 0xFF; would turn all of the outputs on.
>
> Well, let me know if that works. I will also eventually test the
> outputs, but I need to make the counter work for right now.
>
> Don.
>
> On 4/25/06, xioaya12 <> wrote:
> > Don,
> >
> > Did you ever get your 7260 TS-XDIO on DIO2 header to work
> > as outputs ? I saw your snip that was commented out.
> >
> > /***
> > ...
> >
> > for discrete outputs
> > *xdio_r0 = 0x00;
> > *xdio_r1 = 0xFF;
> > ****/
> >
> > and was curious if you got this to work. I tried it and
> > only see 3.3V on ALL the outputs.
> >
> > "This is coming from a SW engineer with a ChE background",
> > so I might be leading down a wrong path, but
> > concerning a very simplistic Breadboard setup: I have a BB
> > with one side 5V TLL and the other side at 3.3V. I use
> > two 74HC05 Hex inverters, they take 2-7V. I have one on
> > each side, VCC at 3.3V and the other at 5.0V (separate supply).
> > (the one at the SBC running at 3.3V VCC, actually off DIO2 pin
16.
> >
> > I tie the GNDs together and use the output of the 3.3V 74HC05
> > to the input of the one running at 5.0V and then use that
> > output for any 5V TTL signals (inverted twice). You could
> > configure the setup to go in the other direction as well I
think.
> >
> > Testing the circuit before connecting the DIO signals worked
> > fine. The 74HC05 (at VCC 5.0V tiggers just fine with 3.3 logic
> > high).
> >
> > I just wish I could get the 7260 TS-XDIO lines to toggle.
> > Let me know if you got your code to run as outputs. I found
> > it strange that the direction logic changed between simple
> > DIO and TS-XDIO setups. (or the documentation had a typo).
> >
> > The opto-isolators are best for production deployment. They
> > also make a bus transeiver made for these applications where
> > you set the direction but I could only find a SMT.
> >
> > Best Regards,
> >
> > Rich
> >
> >
> > --- In "Don W. Carr" <doncarr@> wrote:
> > >
> > > Well, I could see the attachment on my end, maybe because I
sent
> > it. I
> > > suppose they might strip the the attachments off at yahoo.
Anyway,
> > here is
> > > the code pasted directly as text. Don.
> > >
> > > #include <stdio.h>
> > > #include <unistd.h>
> > > #include <sys/time.h>
> > > #include <sys/types.h>
> > > #include <sys/stat.h>
> > > #include <fcntl.h>
> > > #include <sys/mman.h>
> > >
> > >
> > >
>
> /******************************************************************
> > /
> > >
> > > static unsigned char *xdio_start;
> > > static unsigned char *xdio_r0;
> > > static unsigned char *xdio_r1;
> > > static unsigned char *xdio_r2;
> > > static unsigned char *xdio_r3;
> > > static unsigned short *ptr16;
> > >
> > > #define TV_ELAPSED_US(x, y) ((((x).tv_sec - (y).tv_sec) *
> > 1000000) + \
> > > ((x).tv_usec - (y).tv_usec))
> > >
> > >
>
> /******************************************************************
> > ***/
> > >
> > > long calc_dif(long count, long last)
> > > {
> > > if (last > count)
> > > {
> > > // Ok, we rolled over
> > > return count + 65536 - last;
> > > }
> > > else
> > > {
> > > return count - last;
> > > }
> > > }
> > >
> > >
>
> /******************************************************************
> > ***/
> > >
> > > int main(int argc, char *argv[])
> > > {
> > > int fd = open("/dev/mem", O_RDWR|O_SYNC);
> > > //xdio at 0x12c00000-0x12c00003
> > > xdio_start = (unsigned char *) mmap(0, getpagesize(),
> > > PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x12C00000);
> > > xdio_r0 = (unsigned char *) (xdio_start + 0);
> > > xdio_r1 = (unsigned char *) (xdio_start + 1);
> > > xdio_r2 = (unsigned char *) (xdio_start + 2);
> > > xdio_r3 = (unsigned char *) (xdio_start + 3);
> > >
> > > ptr16 = (unsigned short *) xdio_r2;
> > >
> > > *xdio_r0 = 0x40; // ?? give me the value to write here
> > > *xdio_r1 = 0x00; // ?? give me the value to write here
> > > /***
> > > *xdio_r0 = 0x82;
> > > *xdio_r1 = 0x00;
> > > for discrete outputs
> > > *xdio_r0 = 0x00;
> > > *xdio_r1 = 0xFF;
> > > ****/
> > >
> > > printf("Wrote, r0 = 0x43, r1 = 0x00\n");
> > >
> > > struct timeval now;
> > > struct timeval last_time;
> > > gettimeofday(&last_time, NULL);
> > > unsigned short last_count = *ptr16;
> > > while (1)
> > > {
> > > sleep(1);
> > > gettimeofday(&now, NULL);
> > > unsigned short count16 = *ptr16;
> > > int elapsed_time = TV_ELAPSED_US(now, last_time);
> > > long n_pulses = calc_dif((long) count16, (long)
last_count);
> > > double frequency = ((double) n_pulses) / (((double)
> > elapsed_time) /
> > > 1000000);
> > > unsigned char byte0 = *xdio_r2;
> > > unsigned char byte1 = *xdio_r3;
> > > printf("--- %02hhx %02hhx %02hhx %02hhx - %hx %hu %d %d
%
> > 0.0lf\n",
> > > xdio_r0, *xdio_r1, byte0, byte1, count16, count16,
> > n_pulses,
> > > elapsed_time, frequency);
> > >
> > > last_count = count16;
> > > last_time = now;
> > > }
> > > }
> > >
> > >
>
> /******************************************************************
> > /
> > >
> > >
> > >
> > > On 4/17/06, rx7vt <wkuhns@> wrote:
> > > >
> > > > --- In "Don W. Carr" <doncarr@>
wrote:
> > > > >
> > > > > I wrote some code, and it appears to work, but with
glitches,
> > such
> > > > that some
> > > > > times, the new count I read is actually less than the
previous
> > > > count, and,
> > > > > it appears to not count all pulses. I had an external
source
> > set to
> > > > EXACTLY
> > > > > 100 Hz, and expected to get 200 Hz since the xdio counter
> > counts both
> > > > > falling and rising edges, but got consistantly lower.
> > > >
> > > > Looks like attachments don't work. Could you upload the
file to
> > the
> > > > 'files' section? (Or, if I'm missing something about how to
see
> > the
> > > > code that you sent, please enlighten me....)
> > > >
> > > > Thanks...
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > SPONSORED LINKS
> > > > Linux os<http://groups.yahoo.com/gads?
> >
t=ms&k=Linux+os&w1=Linux+os&w2=Hardware&w3=Arms&w4=Computer+internet&
> >
w5=Computer+security&w6=Computer+hardware+security&c=6&s=116&.sig=BJW
> > 5myHQ5naFTMcGbJtFkw>
> > > > Hardware<http://groups.yahoo.com/gads?
> >
t=ms&k=Hardware&w1=Linux+os&w2=Hardware&w3=Arms&w4=Computer+internet&
> >
w5=Computer+security&w6=Computer+hardware+security&c=6&s=116&.sig=y-
> > BHswwhyikFrxIthtmHdw>
> > > > Arms<http://groups.yahoo.com/gads?
> >
t=ms&k=Arms&w1=Linux+os&w2=Hardware&w3=Arms&w4=Computer+internet&w5=C
> >
omputer+security&w6=Computer+hardware+security&c=6&s=116&.sig=VFc2E4u
> > FRtDPNiivNTse7A> Computer
> > > > internet<http://groups.yahoo.com/gads?
> >
t=ms&k=Computer+internet&w1=Linux+os&w2=Hardware&w3=Arms&w4=Computer+
> >
internet&w5=Computer+security&w6=Computer+hardware+security&c=6&s=116
> > &.sig=a5JoGFmV0BGnuTosV_TwhQ> Computer
> > > > security<http://groups.yahoo.com/gads?
> >
t=ms&k=Computer+security&w1=Linux+os&w2=Hardware&w3=Arms&w4=Computer+
> >
internet&w5=Computer+security&w6=Computer+hardware+security&c=6&s=116
> > &.sig=8PsVXc1m7Y17vsjZkWVCyw> Computer
> > > > hardware security<http://groups.yahoo.com/gads?
> >
t=ms&k=Computer+hardware+security&w1=Linux+os&w2=Hardware&w3=Arms&w4=
> >
Computer+internet&w5=Computer+security&w6=Computer+hardware+security&
> > c=6&s=116&.sig=mUV97a_TbfG5v5dQOBfVkA>
> > > > ------------------------------
> >
> > > > YAHOO! GROUPS LINKS
> > > >
> > > >
> > > > - Visit your group "ts-7000
> > <http://groups.yahoo.com/group/ts-7000>"
> >
> > > > on the web.
> > > >
> > > > - To unsubscribe from this group, send an email to:
> > > > <ts-7000-
> > =Unsubscribe>
> > > >
> > > > - Your use of Yahoo! Groups is subject to the Yahoo!
Terms of
> > > > Service <http://docs.yahoo.com/info/terms/>.
> > > >
> > > >
> > > > ------------------------------
> > > >
> > >
> > >
> > >
> > > --
> >
> > > Dr. Don W. Carr
> > > J. G. Montenegro 2258
> > > Guadalajara, Mexico
> > > +52-333-630-0704
> > > +52-333-836-4500 ext 2930
> > >
> >
> >
> >
> >
> >
> >
> >
> > ________________________________
> > YAHOO! GROUPS LINKS
> >
> >
> > Visit your group "ts-7000" on the web.
> >
> > To unsubscribe from this group, send an email to:
> >
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
> >
> > ________________________________
> >
>
>
> --
> Dr. Don W. Carr
> J. G. Montenegro 2258
> Guadalajara, Mexico
> +52-333-630-0704
> +52-333-836-4500 ext 2930
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|