issues with cio dio24h board
- andypugh
-
- Offline
- Moderator
-
- Posts: 23323
- Thank you received: 4948
Having read the info here:
www.mccdaq.com/registermaps/RegMapCIO-DIO24-Series.pdf
It seems very likely that minor changes to the driver written in this thread:
www.linuxcnc.org/component/option,com_ku...imit,6/limitstart,0/
will allow HAL to control your existing hardware.
In fact, I have a feeling that that driver will drive your card completely unmodified.
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
- Posts: 23323
- Thank you received: 4948
Here it is
component pcl720 """Driver for the Advantech PCL 720 card.""";
description """This driver supports the Advantech PCL720 ISA card. It might
work with the PCI version too, but this is untested.
It creates hal pins corresonding to the digital inputs and outputs, but does
not support the the counters/timers.""";
pin in bit pin-##-out[32] "Output pins";
pin out bit pin-##-in[32] "Input pins";
pin out bit pin-##-in-not[32] "Inverted version of each input pin";
param rw unsigned reset-time = 5000 """The time in nanoseconds after the write function
has run to reset the pins for which the "reset" parameter is set.""";
param rw bit pin-##-reset[32] """specifies if the pin should be reset by the "reset"
function""";
param rw bit pin-##-out-invert[32] "Set to true to invert the sense of the output pin";
pin out unsigned wait_clocks;
function read nofp "Reads each of the digital inputs and updates the HAL pins";
function write nofp "Writes the values of the output HAL pins to the digital IO";
function reset nofp """Waits for the length of time specified by the
\fBbreset-time\fP parameter and resets any pins for which the \fBreset\fP
parameter has been set. This can be used to allow step generators to make a step
every thread rather than every other thread. This function must be added to the
thread after the "write" function.
Do not use this function if you do not wish to reset any pins.
the stepgen \fBstep-space\fP parameter should be set to 0 to make use of this
function.""";
variable unsigned base_addr;
variable unsigned out; // write data
variable unsigned inv; // Invert masks
variable unsigned res; // Reset mask
variable u64 write_time;
option count_function yes;
option extra_setup yes;
modparam dummy ioaddr """Base address of card. Separate each card base address
with a comma but no space to load more than one card. eg
loadrt pcl720 ioaddr=0x200,0x200. use 0xNNN to define addresses in Hex""";
license "GPL";
author "Andy Pugh";
;;
#include <asm/io.h>
#define MAX_CHAN 8
static int ioaddr[MAX_CHAN] = {-1, -1, -1, -1, -1, -1, -1, -1};
RTAPI_MP_ARRAY_INT(ioaddr, MAX_CHAN, "Base addresses")
FUNCTION(read){
unsigned R;
int i;
R = inb(base_addr)
+ (inb(base_addr + 1) << 8)
+ (inb(base_addr + 2) << 16)
+ (inb(base_addr + 3) << 24);
for (i = 0;i <= 31;i++){
pin_in(i) = R & (1 << i);
pin_in_not(i) = ~pin_in(i);
}
}
FUNCTION(write){
int i;
unsigned char b;
out = 0;
inv = 0;
for (i = 0;i <= 31 ;i++){
out |= pin_out(i) << i;
inv |= pin_out_invert(i) << i;
}
out ^= inv;
b = (out & 0xff);
outb(b, base_addr);
b = (out & 0xff00) >> 8;
outb(b, base_addr + 1);
b = (out & 0xff0000) >> 16;
outb(b, base_addr + 2);
b = (out & 0xff000000) >> 24;
outb(b, base_addr + 3);
write_time = rtapi_get_time();
}
FUNCTION(reset){
long long deadline;
int i;
unsigned tmp;
unsigned char b;
res= 0;
for (i = 0;i <= 31 ;i++){
res |= pin_reset(i) << i;
}
if (res == 0) {return;} // no pins with reset set
tmp = (out ^ inv) & (~res);
if (tmp == out) {return;} // nothing to reset
if(reset_time > period/4) reset_time = period/4;
//compensate for any time elapsed since the write
rtapi_delay(reset_time - (rtapi_get_time() - write_time));
b = (tmp & 0xff);
outb(b, base_addr);
b = (tmp & 0xff00) >> 8;
outb(b, base_addr + 1);
b = (tmp & 0xff0000) >> 16;
outb(b, base_addr + 2);
b = (tmp & 0xff000000) >> 24;
outb(b, base_addr + 3);
out = tmp;
}
EXTRA_SETUP(){
if (ioaddr[extra_arg] > 0) {
base_addr = ioaddr[extra_arg];
rtapi_print("Loading Advantech pcl720 driver at base addr %X\n", base_addr);
return 0;
}
return -EINVAL;
}
int get_count(void){
int i;
for (i=0; ioaddr[i] > 0 && i < MAX_CHAN; i++){}
return i;
}
Please Log in or Create an account to join the conversation.
- patburden
- Offline
- New Member
-
- Posts: 11
- Thank you received: 0
This info Really boosted my confidence that my old mill will live again.
I will give it a try and report back.
I know there are several people out there with these old
ROBOTOOL CVM1 mills with no software, who will be interested.
THANKS AGAIN!!
Please Log in or Create an account to join the conversation.
- patburden
- Offline
- New Member
-
- Posts: 11
- Thank you received: 0
when I typed sudo comp --install pcl720.c
I got this
make -C /usr/src/linux-headers-2.6.24-16-rtai SUBDIRS=`pwd` CC=gcc V=0 -o /Module.symvers modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.24-16-rtai'
CC [M] /tmp/tmpi3_kWp/pcl720.o
/tmp/tmpi3_kWp/pcl720.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘pcl720’
/tmp/tmpi3_kWp/pcl720.c:2:15: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:2: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before string constant
/tmp/tmpi3_kWp/pcl720.c:2: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:5:39: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:5: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:7: error: stray ‘##’ in program
/tmp/tmpi3_kWp/pcl720.c:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘out’
/tmp/tmpi3_kWp/pcl720.c:8: error: stray ‘##’ in program
/tmp/tmpi3_kWp/pcl720.c:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘out’
/tmp/tmpi3_kWp/pcl720.c:9: error: stray ‘##’ in program
/tmp/tmpi3_kWp/pcl720.c:10: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rw’
/tmp/tmpi3_kWp/pcl720.c:10:39: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:10: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:11:68: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:11: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:12: error: stray ‘##’ in program
/tmp/tmpi3_kWp/pcl720.c:12:84: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:12: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:13:11: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:13: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:14: error: stray ‘##’ in program
/tmp/tmpi3_kWp/pcl720.c:16: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘out’
/tmp/tmpi3_kWp/pcl720.c:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘read’
/tmp/tmpi3_kWp/pcl720.c:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘write’
/tmp/tmpi3_kWp/pcl720.c:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘reset’
/tmp/tmpi3_kWp/pcl720.c:20:23: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:20: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:21: error: stray ‘\’ in program
/tmp/tmpi3_kWp/pcl720.c:21: error: stray ‘\’ in program
/tmp/tmpi3_kWp/pcl720.c:21: error: stray ‘\’ in program
/tmp/tmpi3_kWp/pcl720.c:21: error: stray ‘\’ in program
/tmp/tmpi3_kWp/pcl720.c:26: error: stray ‘\’ in program
/tmp/tmpi3_kWp/pcl720.c:26: error: stray ‘\’ in program
/tmp/tmpi3_kWp/pcl720.c:27:12: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:27: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:31: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘unsigned’
/tmp/tmpi3_kWp/pcl720.c:32: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘unsigned’
/tmp/tmpi3_kWp/pcl720.c:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘unsigned’
/tmp/tmpi3_kWp/pcl720.c:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u64’
/tmp/tmpi3_kWp/pcl720.c:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘count_function’
/tmp/tmpi3_kWp/pcl720.c:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘extra_setup’
/tmp/tmpi3_kWp/pcl720.c:40: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dummy’
/tmp/tmpi3_kWp/pcl720.c:40:25: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:40: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:42:28: error: hexadecimal floating constants require an exponent
/tmp/tmpi3_kWp/pcl720.c:42:39: error: invalid suffix "xNNN" on integer constant
/tmp/tmpi3_kWp/pcl720.c:42:73: warning: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:42: error: missing terminating " character
/tmp/tmpi3_kWp/pcl720.c:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before string constant
/tmp/tmpi3_kWp/pcl720.c:52: error: expected ‘)’ before numeric constant
/tmp/tmpi3_kWp/pcl720.c:68: warning: return type defaults to ‘int’
/tmp/tmpi3_kWp/pcl720.c:68: warning: function declaration isn’t a prototype
/tmp/tmpi3_kWp/pcl720.c: In function ‘FUNCTION’:
/tmp/tmpi3_kWp/pcl720.c:71: error: ‘out’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:71: error: (Each undeclared identifier is reported only once
/tmp/tmpi3_kWp/pcl720.c:71: error: for each function it appears in.)
/tmp/tmpi3_kWp/pcl720.c:72: error: ‘inv’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:74: error: implicit declaration of function ‘pin_out’
/tmp/tmpi3_kWp/pcl720.c:75: error: implicit declaration of function ‘pin_out_invert’
/tmp/tmpi3_kWp/pcl720.c:81: error: ‘base_addr’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:89: error: ‘write_time’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:89: error: implicit declaration of function ‘rtapi_get_time’
/tmp/tmpi3_kWp/pcl720.c: At top level:
/tmp/tmpi3_kWp/pcl720.c:92: warning: return type defaults to ‘int’
/tmp/tmpi3_kWp/pcl720.c:92: warning: function declaration isn’t a prototype
/tmp/tmpi3_kWp/pcl720.c:92: error: redefinition of ‘FUNCTION’
/tmp/tmpi3_kWp/pcl720.c:68: error: previous definition of ‘FUNCTION’ was here
/tmp/tmpi3_kWp/pcl720.c: In function ‘FUNCTION’:
/tmp/tmpi3_kWp/pcl720.c:98: error: ‘res’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:100: error: implicit declaration of function ‘pin_reset’
/tmp/tmpi3_kWp/pcl720.c:103: warning: ‘return’ with no value, in function returning non-void
/tmp/tmpi3_kWp/pcl720.c:105: error: ‘out’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:105: error: ‘inv’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:106: warning: ‘return’ with no value, in function returning non-void
/tmp/tmpi3_kWp/pcl720.c:108: error: ‘reset_time’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:108: error: ‘period’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:111: error: implicit declaration of function ‘rtapi_delay’
/tmp/tmpi3_kWp/pcl720.c:111: error: ‘write_time’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:114: error: ‘base_addr’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:93: warning: unused variable ‘deadline’
/tmp/tmpi3_kWp/pcl720.c: At top level:
/tmp/tmpi3_kWp/pcl720.c:126: warning: return type defaults to ‘int’
/tmp/tmpi3_kWp/pcl720.c:126: warning: function declaration isn’t a prototype
/tmp/tmpi3_kWp/pcl720.c: In function ‘EXTRA_SETUP’:
/tmp/tmpi3_kWp/pcl720.c:128: error: ‘extra_arg’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:129: error: ‘base_addr’ undeclared (first use in this function)
/tmp/tmpi3_kWp/pcl720.c:130: error: implicit declaration of function ‘rtapi_print’
make[2]: *** [/tmp/tmpi3_kWp/pcl720.o] Error 1
make[1]: *** [_module_/tmp/tmpi3_kWp] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.24-16-rtai'
make: *** [modules] Error 2
My question is
Where can I find out "where to and how I should copy this driver"
and also "Where can I find Info on how to "Create" a Hal file
I am completely new to linux and am slowly learning
THANKS
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
-
- Posts: 213
- Thank you received: 3
sudo comp --install pcl720.comp
Notice the difference is comp instead of c for the extension.
Now I am really just trying to see if I know something or not. I am sure one of the guru's will chime in and set us straight.
For the rest (where to find ??) I am finding by reading threads I find wonderful links in them. This forum has IMHO the best help around.
Please Log in or Create an account to join the conversation.
- BigJohnT
-
- Offline
- Administrator
-
- Posts: 7000
- Thank you received: 1175
John
Please Log in or Create an account to join the conversation.
- patburden
- Offline
- New Member
-
- Posts: 11
- Thank you received: 0
mill-desktop:~$ sudo comp --install pcl720.comp
[sudo] password for mill:
Traceback (most recent call last):
File "/usr/bin/comp", line 1297, in <module>
main()
File "/usr/bin/comp", line 1266, in main
process(f, mode, outfile)
File "/usr/bin/comp", line 1140, in process
a, b = parse(filename)
File "/usr/bin/comp", line 386, in parse
f = open(filename).read()
IOError: [Errno 2] No such file or directory: 'pcl720.comp'
it kinda ran "home to momma" and read a file called comp
so I tried the .c and got what you see above
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
-
- Posts: 213
- Thank you received: 3
Please Log in or Create an account to join the conversation.
- BigJohnT
-
- Offline
- Administrator
-
- Posts: 7000
- Thank you received: 1175
John
Please Log in or Create an account to join the conversation.
- patburden
- Offline
- New Member
-
- Posts: 11
- Thank you received: 0
I find it easiest to run the install command from the directory where the comp file is. Have you tried that? Or I guess include the entire path with the filename
ok tried this and got something different
mill-desktop:~$ sudo comp --install /usr/bin/pcl720.comp
Traceback (most recent call last):
File "/usr/bin/comp", line 1297, in <module>
main()
File "/usr/bin/comp", line 1266, in main
process(f, mode, outfile)
File "/usr/bin/comp", line 1140, in process
a, b = parse(filename)
File "/usr/bin/comp", line 387, in parse
a, b = f.split("\n;;\n", 1)
ValueError: need more than 1 value to unpack
I think it is still reading the same file
Please Log in or Create an account to join the conversation.