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.

Where the problem in here ?

Status
Not open for further replies.

xp95

Newbie level 4
Joined
Jun 11, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Egypt
Activity points
1,326
This schema is used to control 16 device through serial port but it gives random results in reality however I have try it in simulation program and it work very well

**broken link removed**

Where the problem in here ?
 

Where is your crystal ? If the MCU actually runs and executes the firmware ?
Did you try blinking LED on this board ?
 

Hi XP95,

Are you sure this is the circuit you want? What you have done here is, try to put two serial IN Parallel OUT shift registers (https://www.fairchildsemi.com/ds/MM/MM74HC595.pdf) to produce the output. This means that when you have given a1 as input, to get the one to the end line (last device) you have to apply 16 clock pulses, with each clock pulse producing the one on the next output.

CLK 1 0 1 0 1 0 1...............1 0 - CLK16
Out1 1 1 0 0 0 0 0...............0 0
Out2 0 0 1 1 0 0 0...............0 0
Out3 0 0 0 0 1 1 0...............0 0
' '
Out16 0 0 0 0 0 0 0...............11

If this is what you need then its pretty OK.

Also I assume you are using the Internal Oscilator of the PIc.

Make sure yu tie the first pin Pin1 of 877 to Vdd via a diode and resistor (4K7)

Vdd ---->|-----/\/\/\------ Pin1
 

Zman said:
Where is your crystal ? If the MCU actually runs and executes the firmware ?
Can you give me more information about crystal (I am beginner and this is my first project :D)
Zman said:
Did you try blinking LED on this board ?

yes ,on breadboard

Added after 3 minutes:

eXnol said:
Hi XP95,

Are you sure this is the circuit you want? What you have done here is, try to put two serial IN Parallel OUT shift registers (https://www.fairchildsemi.com/ds/MM/MM74HC595.pdf) to produce the output. This means that when you have given a1 as input, to get the one to the end line (last device) you have to apply 16 clock pulses, with each clock pulse producing the one on the next output.

CLK 1 0 1 0 1 0 1...............1 0 - CLK16
Out1 1 1 0 0 0 0 0...............0 0
Out2 0 0 1 1 0 0 0...............0 0
Out3 0 0 0 0 1 1 0...............0 0
' '
Out16 0 0 0 0 0 0 0...............11

yeah, and here the used code

Code:
char E=0x45;
char text[16];
char x,i;
void main()
{
trisb=0;
portb=0;
UART1_Init(9600);
i=0;
while(1){
      if(UART1_Data_Ready()){
      text[i]= UART1_Read();
      i++;
      if(i==16){
          i=0;
for(x=0;x<16;x++)
                 {
                 portb.f0=text[x];
                 portb.f1=0;portb.f1=1;
                 }

portb.f2=0;portb.f2=1;}
}
if(portb.f3==1)
    Uart1_Write(E);
}
}

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;

namespace The_control
{
    public partial class Form1 : Form
    {
        SerialPort port;
        public Form1()
        {
            
            InitializeComponent();
            string[] ports = SerialPort.GetPortNames();
            foreach (string port1 in ports)
            {
                coms.Items.Add(port1);
            }
            

        }
        public String convBoolToString(bool[] a)
        {
            string s = null;
            foreach (bool l in a)
            {
                if (l == true) { s = 1 + s; }
                else s = 0 + s;

            }
            return s;
        }
                    

        private void button2_Click(object sender, EventArgs e)
        {
            button1.Enabled = true;
            c.Enabled = true;
            button2.Enabled = false;
            port = new SerialPort(coms.Text, 9600, Parity.None, 8, StopBits.One);
            if (port.IsOpen) port.Close();
            try
            {
                //open serial port
                port.Open();
            }
            catch (System.Exception )
            {
                if (port.IsOpen) port.Close();
            }
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            
            int i;
            bool[] m = new bool[16];
            for (i = 0; i < c.Items.Count  ; i++)
            {
                m[i] = c.GetItemChecked(i);

            }
            //***************************************
     //  MessageBox.Show(convBoolToString(m));
            port.Write(convBoolToString(m));
            port.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
        }



        private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {

            string m;
            m = port.ReadExisting();
            if (m == "E")
            {

                label1.Text = "     FIRE!!!    ";
                label1.BackColor = Color.Red;



            }

        }

eXnol said:
Also I assume you are using the Internal Oscilator of the PIc.

Make sure yu tie the first pin Pin1 of 877 to Vdd via a diode and resistor (4K7)

Vdd ---->|-----/\/\/\------ Pin1

What is the kind of Oscilator i should use ?
 

You may use any kind of oscillator for the PIC but the program should be written to match the speed of the same or command for the same should be given while programming the PIC.
Cheers
 

How can i put the Oscilator in this circuit? (How its connected?)
 

Hey,
check pls the corresponding PIC datasheet, it has in the circuit an oscillator or even XTAL too...
K.
 

Hi, you can connect an external crystal between pins OSC1 and OSC2 of the pic, with two 22pf caps grounding each pin. I think you should seriously read the PIC datasheet : https://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf

and some basic PIC programming manual to get an understanding about setting the configuration registers for Crystal and Other Oscilators, USART configuration etc.

Please read them and then it will be a hundred times easier for you to do it.

Added after 2 minutes:

I donot have much experience programming a uC in C. I usually use ASM instead. So I cannot actually debug your second code easily.
 

i have put the crystal with two 22pf caps grounding each pin as you say and resistor 10k in pin 1 with volt . It gives some orders correct and some wrong (If i open or close led 1,2,3,4,6,8,15 or 16 its response but if i open or close any other led gives error)


(I have read the datasheet 3 times :cry:)
 

Hi,
Is it possible pls that your circuit missed a POR? Refer pls to page 150 of the linked datasheet...

"14.5 Power-on Reset (POR)
A Power-on Reset pulse is generated on-chip when VDD rise is detected (in the range of 1.2V-1.7V).
To take advantage of the POR, tie the MCLR pin to VDD through an RC etwork, as described in Section 14.4 “MCLR”. A maximum rise time for VDD is specified.
See Section 17.0 “Electrical Characteristics” for details."
K.
P.S.:
a 10KOhm Rserial is only by "AT-Cut" XTALs needed, but you must try some different values of the components, its all in X-versions on the market...
 

It doesn't seem like a POR problem. His circuit is working fine from some inputs. I am sorry I can't help with C
 

It doesn't seem like a POR problem. His circuit is working fine from some inputs. I am sorry I can't help with C

please click helped me if you found this useful
 

fuuton,

You should try contributing something useful to this board rather than repeating other people's posts followed by "please click helped me if you found this useful".

Keith.
 

He makes that in the past days on lot of threads! :-( :!: , :?:
K.
 

Yes, I have noticed. I assume he is desperately trying to get some "helped me" points but instead he is just littering the board with cr@p :evil:

By the way, I haven't forgotten about your Airmec. I did have one go at looking for information but drew a blank. I have a note to look again when I have more time.

Keith.
 

:)
Thnx Keith!
I have a scanned datasheet received until past time, but its only a photo + 2 pages data_I have my instrument in original_a photo helps not so much :),
but yet I becam the "official data" as minimum for my orientation...
Im thanking in advance.
Best greetings!
K.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top