Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] pic16f877a and rs232 multiplexer

Status
Not open for further replies.

dxtr

Member level 3
Member level 3
Joined
Apr 27, 2012
Messages
66
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,699
hey everyone
i recently bought a µcam and µdrive (micro sd module) , they are both using rs232 communication .
is there anyway i can do something like this :

**broken link removed**

the pic send command to the Camera to take a picture and send it over , but then the camera will send it to the µdrive instead
any suggestions ??
 

hi, i think the udrive needs control commands to be sent to it to right? i think you should use the PIC to send commands to both devices. but the 16F877a has only 1 uart module right? maybe you can use soft UART for the other device. maybe using a PIC with 2 uart modules is better or you can also try using a PIC with an SPI module for the micro SD and a UART for the uCam (but i think you wouldn't want this because you already have a module for your Micro SD :D ).
 
  • Like
Reactions: dxtr

    dxtr

    Points: 2
    Helpful Answer Positive Rating
i think the udrive needs control commands
yes it needs some commands to write a file on it
maybe you can use soft UART for the other device
yes , i think i can do this , but its not clair to me yet , i mean there is one command sent from PIC to uCam ( take picture and send it back "to the pic" ) , how can i redirect it to the udrive ?
 

the pic send command to the Camera to take a picture and send it over , but then the camera will send it to the µdrive instead
any suggestions ??

If the uCam could effectively communicate directly with the uDrive, why would you need a PIC or any MCU for that matter?

While softUARTs are a solution for some applications, softUARTs are typically limited to maximum BAUD rates of 4800 or 9600 when implemented on a MCU like the PIC16F series.

I believe you'll find these BAUD rate limitations quite restrictive when communicating with devices which normally operate with BAUD rates in the 115,200+ range.

Also due to the PIC16F877A limited RAM resources buffering would be a serious issue effectively slowing both devices down to the BAUD rate of the softUART.

I would recommend utilizing a PIC with two UARTs as the most cost effective options, maybe consider moving up to the PIC18F series.

Other possibilities are the use of external UART with SPI interface, however the cost would probably exceed my recommendation above

Or as ernpao suggested, use a normal SPI SD interface to store the data, rather than the µdrive with the UART, although due to the limited resources of the PIC16F877A, implementation of a FAT filesystem for the SD would be another serious issue.



BigDog
 
  • Like
Reactions: dxtr

    dxtr

    Points: 2
    Helpful Answer Positive Rating
Ernpao is correct, you have to send commands to both devices and they cannot communicate directly with each other without help.

The PIC might have to act as a go-between for the data transfers, reading a byte from the µcam and sending it out again to the µdrive with a write byte instruction. You might need to run the µdrive at a faster baud rate than the µcam so that you have time for the processing to send the data out without losing bytes from the µcam.

You might be able to link the TX of the µcam to the RX of the µdrive through a logic gate to switch it, set up the transfer by setting the write address in the µdrive, then start the µcam sending data and switch the µcam-to-µdrive connection on so that the data goes straight to storage. That might be fiddly to set up though.

Edit: I'm really going to have to learn to type faster!
 
  • Like
Reactions: dxtr

    dxtr

    Points: 2
    Helpful Answer Positive Rating
well , i understand that softuart is not gonna work for me . and i can't make the pic as a bridge as FoxyRick suggested (16f876a don't have enough memory to store jpeg pictures) , but i can use my telit-gm862 module as bridge
what do you say about this guys ?
 

Throw a GSM modem into the mix?

Why?

Wouldn't a much less expensive option be utilizing a PIC with two UARTs?


BigDog
 
  • Like
Reactions: dxtr

    dxtr

    Points: 2
    Helpful Answer Positive Rating
Throw a GSM modem into the mix?
Why?
Wouldn't a much less expensive option be utilizing a PIC with two UARTs?
BigDog
i will use it anyway to send GPS data to my server , so i think there is no harm using it as a bridge
 

There are several PIC18Fs which offer two UARTs, 3+ kB of RAM, operate in the 40-64MHz range with a cost in the $2 to $3 USD range.

**broken link removed**

BigDog
 
There are several PIC18Fs which offer two UARTs, 3+ kB of RAM, operate in the 40-64MHz range with a cost in the $2 to $3 USD range.

**broken link removed**

BigDog

its a good idea , and i can reserve my telit for other uses :)
Thanks for you all guys , you are very nice and helpful people :)
 

Hey dxt we are in the same project.
its a good idea:)
No Dxtr its not , using a PIC18F will need a clock between 40 and 64 MHz, thing that not possible, cause here in Tangier (Morocco) we can have just 4 MHz.
that why we use our pic16f876a with 4MHz not with 8MHz.
 

using a PIC18F will need a clock between 40 and 64 MHz, thing that not possible, cause here in Tangier (Morocco) we can have just 4 MHz.
that why we use our pic16f876a with 4MHz not with 8MHz.

That is completely wrong. The PIC18F clock can run from DC to 40MHz; it has been tested with 455KHz, 2MHz, 4MHz and others. Also, you can use a 4MHz crystal and activate the PLL which multiplies it by 4 to give an internal 16MHz clock.

Can you really only have a 4MHz crystal in Morocco?
 
No Dxtr its not , using a PIC18F will need a clock between 40 and 64 MHz, thing that not possible, cause here in Tangier (Morocco) we can have just 4 MHz.
that why we use our pic16f876a with 4MHz not with 8MHz.

I'm afraid that statement is entirely incorrect.

Besides, the reasons FoxyRick has given, I might also add, many PIC18Fs do not require any external crystal or clock source as they have internal oscillators.

Example, PIC18F24K22:

High Performance RISC CPU:
C Compiler optimized architecture/instruction set
Data EEPROM to 1024 bytes
Linear program memory addressing to 64 Kbytes
Linear data memory addressing to 4 Kbytes
Up to 16 MIPS operation
16-bit wide instructions, 8-bit wide data path
Priority levels for interrupts
31-level, software accessible hardware stack
8 x 8 Single-Cycle Hardware Multiplier
Extreme Low-Power Management with nanoWatt XLP™:
Sleep mode: 100 nA, typical
Watchdog Timer: 500 nA, typical
Timer1 Oscillator: 500 nA @ typical 32 kHz
Flexible Oscillator Structure:
Precision 16 MHz internal oscillator block:
Factory calibrated to ± 1%
Software selectable frequencies range of 31 kHz to 16 MHz
64 MHz performance available using PLL – no external components required

Four Crystal modes up to 64 MHz
Two external Clock modes up to 64 MHz
4X Phase Lock Loop (PLL)
Secondary oscillator using Timer1 @ 32 kHz
Fail-Safe Clock Monitor:
Allows for safe shutdown if peripheral clock stops
Two-Speed Oscillator Start-up
Special Microcontroller Features:
Full 5.5V operation (PIC18F2XK22/4XK22)
Low voltage option available for 1.8V-3.6V operation (PIC18LF2XK22/4XK22)
Self-reprogrammable under software control
Power-on Reset (POR), Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
Programmable Brown-out Reset (BOR)
Extended Watchdog Timer (WDT) with on-chip oscillator and software enable
Programmable code protection
In-Circuit Serial Programming™ (ICSP™) via two pins
In-Circuit Debug via two pins
Analog Features:
Analog-to-Digital Converter (ADC) module:
10-bit resolution
17 analog input channels (PIC18F/LF2XK22)
28 analog input channels (PIC18F/LF4XK22)
Auto acquisition capability
Conversion available during Sleep
Programmable High/Low Voltage Detection (PLVD) module
Charge Time Measurement Unit (CTMU) for mTouch™ support:
Up to 28 channels for button, sensor or slider input
Analog comparator module with:
Two rail-to-rail analog comparators
Comparator inputs and outputs externally accessible and configurable
Voltage reference module with:
Programmable On-chip Voltage Reference (CVREF) module (% of VDD)
Selectable on-chip fixed voltage reference
Peripheral Features:
24/35 I/O pins and 1 input-only pin:
High current sink/source 25 mA/25 mA
Individually programmable weak pull-ups
Individually programmable interrupt-on-pin change
Three external interrupt pins
Up to seven Timer modules:
Up to four 16-bit timers/counters with prescaler
Up to three 8-bit timers/counters
Dedicated, low-power Timer1 oscillator
Up to two Capture/Compare/PWM (CCP) modules
Up to three Enhanced Capture/Compare/PWM
(ECCP) modules with:
One, two or four PWM outputs
Selectable polarity
Programmable dead time
Auto-shutdown and Auto-restart
PWM output steering control
Two Master Synchronous Serial Port (MSSP) modules with two modes of operation:
3-wire SPI (supports all 4 SPI modes)
I2C™ Master and Slave modes (Slave mode with address masking)
Two Enhanced Universal Synchronous Asynchronous Receiver Transmitter modules (EUSART):
Supports RS-232, RS-485 and LIN 2.0
Auto-Baud Detect
Auto Wake-up on Start bit

Also Reference: **broken link removed**, Section: Flexible Oscillator Structure, Page: 3
Flexible Oscillator Structure:
• Precision 16 MHz Internal Oscillator Block:
- Factory calibrated to ± 1%
- Selectable frequencies, 31 kHz to 16 MHz
- 64 MHz performance available using PLL –
no external components required

• Four Crystal modes up to 64 MHz
• Two External Clock modes up to 64 MHz
• 4X Phase Lock Loop (PLL)
• Secondary Oscillator using Timer1 @ 32 kHz
• Fail-Safe Clock Monitor:
- Allows for safe shutdown if peripheral clock stops
- Two-Speed Oscillator Start-up


BigDog
 

Can you really only have a 4MHz crystal in Morocco?
well, to get more than 4 Mhz crystal we have to go get it from an other city "CASABLANCA MOROCCO" its so far :p
by the way ramoneb is working with me

- - - Updated - - -

Precision 16 MHz internal oscillator block:
Factory calibrated to ± 1%
Software selectable frequencies range of 31 kHz to 16 MHz
64 MHz performance available using PLL – no external components required
Thats nice , no external components required
well now i have to read a little bit about the 18f familly before start working on it
 

Thats nice , no external components required
well now i have to read a little bit about the 18f familly before start working on it

Yes and another benefit in using some of the newer PIC18Fs is their extremely low power usage, XLP designation.

• Sleep mode: 20 nA, typical
• Watchdog Timer: 300 nA, typical
• Timer1 Oscillator: 800 nA @ 32 kHz

Which make them ideal for battery powered applications.


BigDog
 
Thank you so much for guiding me through this :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top