Hi i have project where there are few rs232 boards connected to computer and the computer does the processing of switching on and off but i wanna upgrade
i want to use something like CAN BUS or I2C for this like all MCU or slaves connected to RPI by GPIO Pins and these MCU sent data to RPI and in return RPI shall check database and send back yes or no to the corresponding MCU which sent the data and it shall turn on or off the led or mosfet or relay
so how do i do this and what shall i use for fast responding i will be using
MCU like attiny2313 or atmega328p
CAN BUS for higher data transfer rate
and python or C for Programming which ever is better
apache database
and i would like to have few examples to make something like this
Fast is a subjective term. Sounds data transfer rate is not really a problem considering you are controlling relays and LEDs. I2C is not designed for long wiring such as you will have. CAN will work but has a limited distance. Consider using RS485 you can use several thousand feet of wire if wired properly. It can go over 100K baud if properly set up. I think, just guessing, that 9600 Baud will be more then fast enough. Set your Pi up so it poles each MCU and then gets the response. You may want to add a check number to your protocol along with MCU address. You will have to add the address with Can or most other methods. As far as software, either will work, use the one you are most familiar with. If new to both I would suggest starting with "C". This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
gilshultz:
Fast is a subjective term. Sounds data transfer rate is not really a problem considering you are controlling relays and LEDs. I2C is not designed for long wiring such as you will have. CAN will work but has a limited distance. Consider using RS485 you can use several thousand feet of wire if wired properly. It can go over 100K baud if properly set up. I think, just guessing, that 9600 Baud will be more then fast enough. Set your Pi up so it poles each MCU and then gets the response. You may want to add a check number to your protocol along with MCU address. You will have to add the address with Can or most other methods. As far as software, either will work, use the one you are most familiar with. If new to both I would suggest starting with “C”. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
Distance is no problem all slaves have about no more than a feet distance between them as each is connected to one another would like to have multiple slaves (say about more than 10)and all connected to rpi and have flawless system
As long as you are starting from scratch, include some reporting of those slaves not responding to a polling from the master, so you will know who to fix.
Paul_KD7HB:
As long as you are starting from scratch, include some reporting of those slaves not responding to a polling from the master, so you will know who to fix.
Paul
but where should i start what library should i use i am just trying to get done properly so please help
akash614:
it would just be a barcode scanner data to RPI and RPI to MCU Yes or no decision
You have a barcode scanner in mind already?
Those tend to come with USB connection, so it may be easier to connect them directly to the Pi.
highest speed as possible for the task should not take more than 2 sec
No vague terms. Numbers are needed.
How much data - how many exact bytes? How much time does the Pi need to come with an answer? How much data (in bytes) to transmit back? What is your protocol overhead? Now you can calculate the minimum speed needed.
it depends if you want to connect slave to slave ..... to slave to master
or simple each slave to master
That's part of your system architecture design.
Rpi Will be single Master and slaves are MCU upto N numbers
What is the required upper number for N?
i am thinking as simple and small as possible like attiny and only DIP Package
DIP isn't getting you nearly to "as small as possible". DIP is huge compared to QFN. An ATtiny85 in DIP is bigger than an ATmega238P in TQFP package
wvmarle:
You have a barcode scanner in mind already?
Those tend to come with USB connection, so it may be easier to connect them directly to the Pi.
No vague terms. Numbers are needed.
How much data - how many exact bytes? How much time does the Pi need to come with an answer? How much data (in bytes) to transmit back? What is your protocol overhead? Now you can calculate the minimum speed needed.
That's part of your system architecture design.
What is the required upper number for N?
DIP isn't getting you nearly to "as small as possible". DIP is huge compared to QFN. An ATtiny85 in DIP is bigger than an ATmega238P in TQFP package
the barcode scanner is a usb , keyboard, rs232 type 3 in functionality so i opt to choose rs232 for communication with MCU each slave has one scanner connected to it self
i have not started the project so i guess 1 Mbit/sec speed is better for me
i would like to have system like in image provided
N number can be like say above 10 and upto 50 and even more
size is not a huge problem i taking dip as it is easy and fast solder rather than SMD where it is time consuming in bridging pin or anything
If you want 50 or more of the same you're in numbers where it's silly to try to solder it all by hand, to much work. That's the numbers where you order the assembled PCB. Even by hand SMD is easily faster than THT provided you have the proper tools (which are cheap and easy to get by). 1.27mm pitch is easy to do without bridging when you use a solder paste stencil.
Nonetheless, you'd better try to get one going first before figuring out the PCB.
That image misses at least the interface between MCU and barcode scanner; you need an RS232 to TTL Serial adapter there.
wvmarle:
If you want 50 or more of the same you’re in numbers where it’s silly to try to solder it all by hand, to much work. That’s the numbers where you order the assembled PCB. Even by hand SMD is easily faster than THT provided you have the proper tools (which are cheap and easy to get by). 1.27mm pitch is easy to do without bridging when you use a solder paste stencil.
Nonetheless, you’d better try to get one going first before figuring out the PCB.
That image misses at least the interface between MCU and barcode scanner; you need an RS232 to TTL Serial adapter there.
What is the role of the MCU in this, really?
dont worry about how i will get all soldered
just i need libraries to find out which how and what to use and few examples based of it
and few references based on rpi also to use can with it
the image is just to show how i would like to connect all slaves to master and i will max232 for rs232 to ttl
receive signal from scanner and forward it to rpi with its address and in return rpi sends back yes or no by checking database and later in MCU if yes activate relay or led