How to adapt the extended IO?
19 Jul 2022 08:15 #247752
by chen1234
How to adapt the extended IO? was created by chen1234
hi guys,
i have a raspberry pi but it doesn't have enough pins,
i have an IO expansion module, i can control the expanded IO,
but i don't know how to give this expanded IO to my axis (x, y,z...),
where should I look at this section?
please,chen
I want to give the extended IO to my axis like this:[/code]
i have a raspberry pi but it doesn't have enough pins,
i have an IO expansion module, i can control the expanded IO,
but i don't know how to give this expanded IO to my axis (x, y,z...),
where should I look at this section?
please,chen
I want to give the extended IO to my axis like this:
[code]net home-x joint.0.home-sw-in <= parport.0.pin-11-in
Please Log in or Create an account to join the conversation.
21 Jul 2022 18:32 #247978
by andypugh
Replied by andypugh on topic How to adapt the extended IO?
What sort of expansion module? I2C? SPI? something else?
You might need to write a HAL driver.
You might need to write a HAL driver.
Please Log in or Create an account to join the conversation.
22 Jul 2022 02:50 #248001
by chen1234
Replied by chen1234 on topic How to adapt the extended IO?
thanks,and
My expansion device is IIC expansion (PCF8574), so how do I configure this hal driver and where can I see this?
My expansion device is IIC expansion (PCF8574), so how do I configure this hal driver and where can I see this?
Please Log in or Create an account to join the conversation.
22 Jul 2022 08:13 #248014
by andypugh
Replied by andypugh on topic How to adapt the extended IO?
Do you need this IO to be realtime?
There are tutorials on the web about enabling I2C on the Pi (for example learn.adafruit.com/adafruits-raspberry-p...etup/configuring-i2c )
For non-realtime access you can use the built-in drivers. I think that for realtime use you would need to mmap the device. I suggest looking at the i2C kernel driver tutorials out there (but don't follow them) and look at the hal_pi_gpio LinuxCNC driver and try to combine the two.
You can probably write this driver using halcompile.
There are tutorials on the web about enabling I2C on the Pi (for example learn.adafruit.com/adafruits-raspberry-p...etup/configuring-i2c )
For non-realtime access you can use the built-in drivers. I think that for realtime use you would need to mmap the device. I suggest looking at the i2C kernel driver tutorials out there (but don't follow them) and look at the hal_pi_gpio LinuxCNC driver and try to combine the two.
You can probably write this driver using halcompile.
The following user(s) said Thank You: chen1234
Please Log in or Create an account to join the conversation.
22 Jul 2022 10:10 #248017
by chen1234
Replied by chen1234 on topic How to adapt the extended IO?
thanks andy,
I configured the Raspberry Pi to enable I2C,
I used python-smbus to test this expansion device, and I can control the high and low levels of this IO pin very well.
However, I don't know how to configure this io to my hal, thank you for your reply, I'll go and try to write this driver.
hope it won't be difficult .
I configured the Raspberry Pi to enable I2C,
I used python-smbus to test this expansion device, and I can control the high and low levels of this IO pin very well.
However, I don't know how to configure this io to my hal, thank you for your reply, I'll go and try to write this driver.
hope it won't be difficult .
Please Log in or Create an account to join the conversation.
22 Jul 2022 10:39 #248019
by andypugh
Replied by andypugh on topic How to adapt the extended IO?
If you can find a way to read / write to the board using inb() and outb() then it is easy to write the HAL driver. (That is how the paralell port driver on x86 works)
hal_pi_gpio wrks somewhat similarly, except that it uses mmap to allow it to read the port data from (virtual?) memory locations:
github.com/LinuxCNC/linuxcnc/blob/master...rivers/hal_pi_gpio.c
I think that googling for Pi I2C and mmap might get you the required info.
It might well be as easy as changing the /dev/gpiomem here:
github.com/LinuxCNC/linuxcnc/blob/master...s/hal_pi_gpio.c#L164
to /dev/i2c-1 (or i2c-0)
raspberry-projects.com/pi/programming-in...ng-the-i2c-interface
I think that I would suggest starting with a _very_ simple HAL component written with halcompile that first of all reads the data into a single u32 HAL pin using the sample code above, then look at memory-mapping that port, and only then worry about setting individual bit-type HAL pins and configuring port directions.
hal_pi_gpio wrks somewhat similarly, except that it uses mmap to allow it to read the port data from (virtual?) memory locations:
github.com/LinuxCNC/linuxcnc/blob/master...rivers/hal_pi_gpio.c
I think that googling for Pi I2C and mmap might get you the required info.
It might well be as easy as changing the /dev/gpiomem here:
github.com/LinuxCNC/linuxcnc/blob/master...s/hal_pi_gpio.c#L164
to /dev/i2c-1 (or i2c-0)
raspberry-projects.com/pi/programming-in...ng-the-i2c-interface
I think that I would suggest starting with a _very_ simple HAL component written with halcompile that first of all reads the data into a single u32 HAL pin using the sample code above, then look at memory-mapping that port, and only then worry about setting individual bit-type HAL pins and configuring port directions.
The following user(s) said Thank You: chen1234
Please Log in or Create an account to join the conversation.
09 Aug 2022 23:30 - 09 Aug 2022 23:33 #249435
by cakeslob
Replied by cakeslob on topic How to adapt the extended IO?
Hey chen, I also have a PCF8574. I havent tried to use it yet, but gathered resources and examples related to i2c expander.
This one is for DAC/ temp sensor,
github.com/bosston88/LinuxCNCRPi/blob/master/mcp3421.c
github.com/bosston88/LinuxCNCRPi/blob/master/mcp3421.h
github.com/bosston88/LinuxCNCRPi/blob/master/si7021.c
This is for different i2c io expander
github.com/bosston88/LinuxCNCRPi/tree/master/archive
github.com/sleepybishop/linuxcnc/blob/fi...hal/user_comps/i2c.c
github.com/sleepybishop/linuxcnc/blob/fi...user_comps/sx1509b.c
This one is for DAC/ temp sensor,
github.com/bosston88/LinuxCNCRPi/blob/master/mcp3421.c
github.com/bosston88/LinuxCNCRPi/blob/master/mcp3421.h
github.com/bosston88/LinuxCNCRPi/blob/master/si7021.c
This is for different i2c io expander
github.com/bosston88/LinuxCNCRPi/tree/master/archive
github.com/sleepybishop/linuxcnc/blob/fi...hal/user_comps/i2c.c
github.com/sleepybishop/linuxcnc/blob/fi...user_comps/sx1509b.c
Last edit: 09 Aug 2022 23:33 by cakeslob.
The following user(s) said Thank You: chen1234
Please Log in or Create an account to join the conversation.
Time to create page: 0.168 seconds