Professional Documents
Culture Documents
UDP Control and Monitoring With PIC Microcontroller - StudentCompanion PDF
UDP Control and Monitoring With PIC Microcontroller - StudentCompanion PDF
0
PROJECTS, MIKROC PROJECTS, INTERNET OF THINGS PROJECTS ETHERNET UDP-BASED CONTROL AND MONITORING WITH PIC MICROCONTROLLER – MIKROC
B.Tech Projects, B.Tech projects for ECE/CSE/Computer Science Students, B.tech./M.Tech Final Year Projects, BTech final year projects, C#, ENC28J60,
Ethernet, Ethernet Communication, Final Year Projects for Electronics, Final Year Projects For Engineering Students, GUI, HMI, Home Automation, Human-
Machine Interface, Internet of Things, IoT, Microcontroller, Microcontroller GUI, MikroC, PIC, Projects, Proteus, Relay, SCADA, simulate ENC28J60, Simulate
Ethernet, UDP, UDP Based Control, Visual Studio, Visual Studio 2015, Visual Studio 2017, winpcap
mikroC Pro for PIC Tutorial -81- Project 16 Ethernet UDP-Based Control and Monitoring, part 1
ZA R
EU R
US D
GBP
BWP
Ethernet is the leading wired standard for networking as it enables to connect a very large number of computers, microcontrollers and other
computer-based equipment to one another.
In this project we are going to learn how to control any device like an LED, a relay, a light bulb or a motor connected to a PIC Microcontroller from
a remote location using a customized computer Graphical User Interface (GUI) software designed with C#.
A number of client computers from different locations can be used to control the field devices from anywhere. Communication between the client
computer and the microcontroller is via UDP protocol. With the help of a router connected to the internet, these devices can be controlled or
monitored anywhere in the world in real time.
This project can be used as a base for Final Year Project For electronic and Computer Science Engineering Students.
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 1/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
In this project a PC GUI Software is designed with C# to control a motor and a light bulb connected to a PIC microcontroller using relays. We’re
gonna also read periodically the temperature and display it graphically on the screen and plot a live chart of temperature variations.
With a GUI Software unlike a simple web browser as we learned from Web-Based Control and Monitoring with PIC Microcontroller project, we will
have more flexibility how we can design the GUI software. We could easily create some sort of SCADA software by directly interacting with devices
such as sensors, valves, pumps, motors and more through Human-Machine Interface (HMI) software.
It’s easy to also record events into a log file, send notification messages via email or SMS or raise some audible alarms.
ZA R
GBP
TCP protocol provides reliable ordered delivery of packets. It uses error detection, re-transmissions and acknowledgements. Typical TCP
applications include email and web browsing.
UDP protocol doesn’t care if every packet is received. This enables faster transmissions. Typical UDP applications include VoIP and music BWP
streaming.
TCP is strictly used for point to point or unicast transmissions
UDP can be used for unicast (one to one), multicast (one to many) and broadcast (one to all) transmissions.
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 2/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
We are using two buttons to control the devices connected to PIC microcontroller. By clicking on the BULB button, it will change the color to a lit
BULB and Switch ON the BULB connected to the PIC. Clicking it again with turn the BULB OFF.
The FAN button controls the FAN connected to the PIC, clicking it will turn it ON and clicking it again will turn it OFF.
A Temperature Gauge displays the temperature graphically every 2 seconds and a live chart plots the temperature variations continuously.
To enhance the display, we also created an analog clock. A File menu has buttons to Connect/Disconnect, Settings and Exit.
In the Settings dialog box, the skin of the application can be set from Blue, Light Blue, Dark, Gray, Black, White, Dark, Coffee, Sky
Blue, Caramel, Silver, Green and Pink.
ZA R
You can also set the IP address of the PIC microcontroller and the Port number we’re gonna communicate with.
EU R
Port numbers are used to identify processes running in the applications on a host. For example in one PC, more than one applications that require
TCP/IP communications can run at the same time like a web browser and an email client and both will send and receive packets with the same IP US D
address. The Transport layer will differentiate a web browser packet from an email packet using port numbers.
Some well-know port numbers have been reserved for specific applications, typically for server application. GBP
Client side port numbers are generated and assigned by the Transport layer. They could be any number from 1024 to 65535. These port numbers
are typically allocated for short term use, our application uses port 10001
All packets that travel on the web must use the Internet communications protocol. This means that the source IP address, destination address
must be provided in the packet. Some data packets also contain a port number like TCP/IP and UDP.
This simple code below shows the steps to send UDP data from client to server. In this example we are sending a ‘2’ to the PIC microcontroller.
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 3/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
1 using System.Net.Sockets;
2 using System.Net;
3
4 public byte[] Txt = new byte[1];
5 public UdpClient ClientSocket = new UdpClient();
6
7 //Load IP Address and Port number from settings
8 public string ServerIPAddress = Properties.Settings.Default.IPaddress.ToString();
9 public int PortNumber =Convert.ToInt16( Properties.Settings.Default.PortNumber);
10
11 ClientSocket.Connect(ServerIPAddress, PortNumber); //Connect
12 Txt[0] = 2;
13 ClientSocket.Send(Txt, 1); //Send number 2
The first task is to create a UDP Client object (public UdpClient ClientSocket = new UdpClient();). This is a socket that can send UDP packets.
ClientSocket.Connect() takes two arguments, the server IP address and the port number, these values are saved in application settings. A port
number is selected arbitrarily. Here, the port number 10001 will be read from the application settings, remember this number it is not in the first
1024 port numbers reserved for specific use by IANA.
To detect incoming data, the application will become a server, the code below shows the steps to receive a temperature data from the PIC.
A key feature of servers is multi-threading, they can handle hundreds of simultaneous requests. In this case, we must have at least two threads:
one deals with incoming UDP data, and the other one the main thread to execute the rest of the program like buttons click events or sending data
to PIC. This will make sure the user interface does not appear hung.
Below is the complete code of the application. You can also download the full Visual studio project and the end of this article.
1 using System;
2 using System.Text;
3 using System.Windows.Forms;
4 using DevExpress.XtraEditors;
5 using System.Net.Sockets;
6 using System.Net;
7 using DevExpress.XtraGauges.Win.Gauges.Circular;
8 using DevExpress.XtraGauges.Core.Model;
9 using System.Threading;
10 using DevExpress.XtraCharts;
11
12 namespace UDP_Control_Monitoring
13 {
14 public partial class Form1 : DevExpress.XtraBars.Ribbon.RibbonForm
15 {
16 public byte[] Txt = new byte[1];
17 public UdpClient ClientSocket = new UdpClient();
18
19 //Load IP Address and Port number
20 public string ServerIPAddress = Properties.Settings.Default.IPaddress.ToString();
21 public int PortNumber =Convert.ToInt16( Properties.Settings.Default.PortNumber);
22
23 //Clock
24 ArcScaleComponent scaleMinutes, scaleSeconds;
25 int lockTimerCounter = 0;
26 public Form1()
27 {
28 InitializeComponent();
29
30 //clock
31 scaleMinutes = Clock.AddScale();
32 scaleSeconds = Clock.AddScale();
33 Privacy - Terms
34 scaleMinutes.Assign(scaleHours);
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 4/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
35 scaleSeconds.Assign(scaleHours);
36
37 arcScaleNeedleComponent2.ArcScale = scaleMinutes;
38 arcScaleNeedleComponent3.ArcScale = scaleSeconds;
39 timer1.Start();
40 timer1_Tick(null, null);
41
42 linearScaleComponent1.Value = 0; //initialize scale to 0
43
44 //chart
45 timer2.Interval = interval;
46 }
47
48 void UpdateClock(DateTime dt, IArcScale h, IArcScale m, IArcScale s)
49 {
50 int hour = dt.Hour < 12 ? dt.Hour : dt.Hour - 12;
51 int min = dt.Minute;
52 int sec = dt.Second;
53 h.Value = (float)hour + (float)(min) / 60.0f;
54 m.Value = ((float)min + (float)(sec) / 60.0f) / 5f;
55 s.Value = sec / 5.0f;
56 }
57
58 private void btnExit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
59 {
60 ClientSocket.Close();
61 Environment.Exit(Environment.ExitCode);
62 }
63 bool connected = false;
64 private void btnConnect_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
65 {
66
67 try
68 {
69 ClientSocket.Connect(ServerIPAddress, PortNumber);
70 btnDisconnect.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
71 btnConnect.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
72 barStaticConnect.Caption = "Connected!";
73 btnDisconnectImage.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
74 btnConnectImage.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
75
76 groupBoxLightBulb.Enabled = true;
77 groupBoxFan.Enabled = true;
78 ZA R
79 connected = true;
80 }
81 catch (Exception ex)
EU R
82 {
83 XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
84 }
85 US D
86
87 }
88 GBP
89 private void btnDisconnect_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
90 {
91 try
BWP
92 {
93 btnDisconnect.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
94 btnConnect.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
95 barStaticConnect.Caption = "Disconnected!";
96 btnDisconnectImage.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
97 btnConnectImage.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
98
99 btnFanON.Visible = false;
100 btnFanOFF.Visible = true;
101 btnLightON.Visible = false;
102 btnLightOff.Visible = true;
103 groupBoxLightBulb.Enabled = false;
104 groupBoxFan.Enabled = false;
105
106 Txt[0] = 0;
107 ClientSocket.Send(Txt, 1);
108 PauseResume();
109 }
110 catch (Exception ex)
111 {
112 XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
113 }
114 }
115
116 bool LightON = false;
117 bool MotorON = false;
118 private void btnLightOff_Click(object sender, EventArgs e)
119 {
120 if (MotorON== true)
121 {
122 Txt[0] = 3;
123 ClientSocket.Send(Txt, 1);
124 btnLightOff.Visible = false;
125 btnLightON.Visible = true;
126 LightON = true;
127 }
128 else
129 {
130 Txt[0] = 1;
131 ClientSocket.Send(Txt, 1);
132 btnLightOff.Visible = false ;
133 btnLightON.Visible = true;
Privacy - Terms
134 LightON = true;
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 5/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
135 }
136
137
138 }
139
140 private void btnLightON_Click(object sender, EventArgs e)
141 {
142 if (MotorON == true)
143 {
144 Txt[0] = 2;
145 ClientSocket.Send(Txt, 1);
146 btnLightOff.Visible = true;
147 btnLightON.Visible = false;
148 LightON = false;
149 }
150 else
151 {
152 Txt[0] = 0;
153 ClientSocket.Send(Txt, 1);
154 btnLightOff.Visible = true;
155 btnLightON.Visible = false;
156 LightON = false;
157 }
158 }
159
160 private void btnFanOFF_Click(object sender, EventArgs e)
161 {
162 if (LightON == true)
163 {
164 Txt[0] = 3;
165 ClientSocket.Send(Txt, 1);
166 btnFanOFF.Visible = false;
167 btnFanON.Visible = true;
168 MotorON = true;
169 }
170 else
171 {
172 Txt[0] = 2;
173 ClientSocket.Send(Txt, 1);
174 btnFanOFF.Visible = false;
175 btnFanON.Visible = true;
176 MotorON = true;
177 }
178 } ZA R
179
180 private void btnFanON_Click(object sender, EventArgs e)
181 {
EU R
182 if (LightON == true)
183 {
184 Txt[0] = 1;
185 ClientSocket.Send(Txt, 1); US D
186 btnFanOFF.Visible = true;
187 btnFanON.Visible = false;
188 MotorON = false; GBP
189 }
190 else
191 {
BWP
192 Txt[0] = 0;
193 ClientSocket.Send(Txt, 1);
194 btnFanOFF.Visible = true;
195 btnFanON.Visible = false;
196 MotorON = false;
197 }
198 }
199
200 private void timer1_Tick(object sender, EventArgs e)
201 {
202 if (lockTimerCounter == 0)
203 {
204 lockTimerCounter++;
205 UpdateClock(DateTime.Now, scaleHours, scaleMinutes, scaleSeconds);
206 lockTimerCounter--;
207 }
208 }
209
210 private void btnSettings_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
211 {
212 frmSettings frm = new frmSettings();
213 frm.ShowDialog();
214 }
215
216 private void Form1_Load(object sender, EventArgs e)
217 {
218 Thread thdUDPServer = new Thread(new ThreadStart(serverThread));
219 CheckForIllegalCrossThreadCalls = false;
220 thdUDPServer.Start();
221 }
222 float temp;
223 public void serverThread()
224 {
225 UdpClient udpClient = new UdpClient(PortNumber);
226 while (true)
227 {
228 IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
229 byte[] receiveBytes;
230 receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
231
232 if (connected)
233 {
Privacy - Terms
234 try
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 6/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
235 {
236 string returnData = Encoding.ASCII.GetString(receiveBytes);
237 temp = float.Parse(returnData, System.Globalization.CultureInfo.InvariantCulture);
238 linearScaleComponent1.Value = temp;
239 }
240 catch (Exception ex)
241 {
242 XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
243 }
244
245 }
246 }
247 }
248
249 const int interval = 3;
250
251 static RegressionLine GetRegressionLine(Series series)
252 {
253 if (series != null)
254 {
255 SwiftPlotSeriesView swiftPlotView = series.View as SwiftPlotSeriesView;
256 if (swiftPlotView != null)
257 foreach (Indicator indicator in swiftPlotView.Indicators)
258 {
259 RegressionLine regressionLine = indicator as RegressionLine;
260 if (regressionLine != null)
261 return regressionLine;
262 }
263 }
264 return null;
265 }
266
267
268 int TimeInterval { get { return Convert.ToInt32(spnTimeInterval.EditValue); } }
269 Series Series1 { get { return chart.Series.Count > 0 ? chart.Series[0] : null; } }
270 RegressionLine Regression1 { get { return GetRegressionLine(Series1); } }
271
272 void SetPauseResumeButtonText()
273 {
274 btnPauseResume.Text = timer2.Enabled ? "Pause" : "Resume";
275 }
276
277 private void timer2_Tick(object sender, EventArgs e)
278 { ZA R
279 if (Series1 == null )
280 return;
281 DateTime argument = DateTime.Now;
EU R
282 SeriesPoint[] pointsToUpdate1 = new SeriesPoint[interval];
283 for (int i = 0; i < interval; i++)
284 {
285 pointsToUpdate1[i] = new SeriesPoint(argument, temp); US D
286 argument = argument.AddMilliseconds(1);
287 }
288 DateTime minDate = argument.AddSeconds(-TimeInterval); GBP
289 int pointsToRemoveCount = 0;
290 foreach (SeriesPoint point in Series1.Points)
291 if (point.DateTimeArgument < minDate)
BWP
292 pointsToRemoveCount++;
293 if (pointsToRemoveCount < Series1.Points.Count)
294 pointsToRemoveCount--;
295 AddPoints(Series1, pointsToUpdate1);
296 if (pointsToRemoveCount > 0)
297 {
298 Series1.Points.RemoveRange(0, pointsToRemoveCount);
299 }
300 SwiftPlotDiagram diagram = chart.Diagram as SwiftPlotDiagram;
301 if (diagram != null && (diagram.AxisX.DateTimeScaleOptions.MeasureUnit == DateTimeMeasureUnit.Millisecond || diagram
302 diagram.AxisX.WholeRange.SetMinMaxValues(minDate, argument);
303 }
304 void AddPoints(Series series, SeriesPoint[] pointsToUpdate)
305 {
306 if (series.View is SwiftPlotSeriesViewBase)
307 series.Points.AddRange(pointsToUpdate);
308 }
309 private void PauseResume()
310 {
311 timer2.Enabled = !timer2.Enabled;
312 SetPauseResumeButtonText();
313 }
314 private void btnPauseResume_Click(object sender, EventArgs e)
315 {
316 PauseResume();
317 }
318
319
320
321 private void chRegression_CheckedChanged_1(object sender, EventArgs e)
322 {
323 if (Regression1 != null)
324 Regression1.Visible = chRegression.Checked;
325
326 }
327
328 }
329 }
Circuit Diagram
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 7/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
Figure 4 below shows the circuit diagram. The interface between the PIC18F45K22 microcontroller and the ENC28J60 Ethernet controller chip is
based on the SPI bus protocol, The SI, SO, and SCK pins of the Ethernet chip are connected to SPI pins (SDO, SDI and SCLK) of the microcontroller.
The Ethernet controller chip operates at 3.3V, its output SO pin cannot drive the microcontroller input pin without a voltage translator if the
microcontroller is operated at 5V.
To make the design of Ethernet applications easy, there are ready made boards that include the EC28J60 controller, voltage translation chip and an
RJ45 connector. Figure 5 below shows the the mikroElektronika Serial Ethernet Board. This is a small board that plugs in directly to PORTC of
the EasyPI CV7 development board via a 10-way IDC plug simplifying the development of embedded Ethernet projects. This board is equipped
with an EC28J60 Ethernet controller chip, a 74HCT245 voltage translation chip, three LEDs, a 5 to 3.3 voltage regulator and an RJ45 connector with
an integrated transformer.
ZA R
EU R
US D
GBP
BWP
Relay 1 and Relay 2 are connected to the microcontroller RD0 and RD1 output pins. A control signal to energize or de-energize these relays, will
also control the devices connected to them like a light bulb, a fan or a gate motor.
If the PC and the Ethernet controller are on the same network and close to each other, then the two can be connected together using a crossover
Ethernet cable, otherwise a hub or a switch may be required. In this case a straight cable can be used to connect the PC to the hub/switch and
another straight cable to connect the Microcontroller to the hub/switch. If the PC and the microcontroller are located on different networks and
are not close to each other, then routers may be required to establish connectivity between them.
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 8/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
You can easily create a PCB for this project as we have learned in our PCB start to finish tutorials, all you need is to get a good PCB prototyping
company that will offer your good quality PCBs at a good price. We recommend PCBWay.com, a China Shenzhen-based manufacturer specializing ZA R
in PCB prototyping, small-volume production and PCB Assembly service all under one.
EU R
They are now running a PCB contest until 12 December to provide a platform for hardware hackers, makers, Electronic Engineers, Hobbyists and
artists to compete to build a better future with open hardware. You could also win cash prize money of $1000. So hurry-up now, post your project US D
or vote for your favorite project before the deadline.
GBP
To learn more, please read this article:
BWP
Join PCB Design Contest and Stand a Chance to Win $1000 in Cash
or click on the image below to visit the PCB Design Contest Page to get all the information.
To learn how to simulate the ENC28J60 wit Proteus, please watch the video below for all the steps:
mikroC Pro for PIC Tutorial -80- Project 15 Web-Based Control and Monitoring, part 2
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 9/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
This project is fairly easy to understand, these are basically the few steps to control a device from a remote PC:
Step 1:
Set the MAC Address and IP Address. To access your PIC outside your loacal network or from internet, the DNS, Gateway address and Subnet may
also be defined here. Our local network parameters are as follows:
Step 2:
US D
In the main program, set PORTD pins as Digital input/output pins and pin RA0 as analog input pin for the LM35 temperature sensor.
Initialize Timer0 to generate a timer interrupt every 2 second. GBP
Initialize the SPI module of the microcontroller and Initialize the Serial Ethernet module chip ENC28J60
BWP
Step 3:
Write the code within the Spi_Ethernet_userUDP function that will interpret the commands from the UDP client then energize/de-energize the
relays on PORTD by checking any data recieved on port 10001
Step 4:
Read received data in an endless loop using the function “SPI_Ethernet_doPacket()”. When a timer interrupt occurs every 2 seconds, read the
temperature value and send it to remote PC using the function “SPI_Ethernet_sendUDP()”.
To learn more how to use the ENC28J60 Ethernet Controller library read:
Step 5:
Generate 2 Second timer interrupt using the Timer Calculator.
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 10/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 11/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
66 T0CON = 0x85;
67 TMR0H = 0x0B;
68 TMR0L = 0xDC;
69 GIE_bit = 1;
70 TMR0IE_bit = 1;
71 }
72
73 void Interrupt(){
74 if (TMR0IF_bit){
75 TMR0IF_bit = 0;
76 TMR0H = 0x0B;
77 TMR0L = 0xDC;
78 flag = 1;
79 }
80 }
81
82
83 //
84 // Start of MAIN program
85 //
86 void main()
87 {
88 unsigned int temperature;
89 float mV;
90 unsigned char txt[15];
91 flag = 0;
92 InitTimer0(); //// Initialize Timer0
93
94 ANSELA = 1; // Configure PORTA as Analog
95 ANSELC = 0; // Configure PORTC as Digital I/O
96 ANSELD = 0; // Configure PORTD as Digital I/O
97 TRISD = 0; // Configure PORTD as output
98 PORTD = 0; // Clear PORTD to start with
99 TRISA.RA0 = 1; //Configure RA0 as input
100
101 SPI1_Init(); // Initialize SPI module
102 SPI_Ethernet_Init(MACAddr, IPAddr, 0x01); // Initialize Ethernet module
103
104 ADC_Init(); // Initialize ADC
105 while(1) // Loop forever
106 {
107 SPI_Ethernet_doPacket(); // Process next received packet
108
109 //Get temperature value and send it to remote PC every 2 seconds ZA R
110 if (flag) //Check if there is an Interrupt call
111 {
112 // LATD.F1 = ~LATD.F1 ;
EU R
113 temperature = ADC_Read(0); //Get 10-bit results of AD Conversion
114 mV= temperature * 5000.0/1023.0; // Convert to mV
115 mV = mV/10.0; //Convert mV to temperature in Celcius
116 FloatToStr( mV,txt); //Convert Temperature to string US D
117 txt[4]=0;
118 // send Temperature to remote PC, from UDP port 10001 to UDP port 10001
119 SPI_Ethernet_sendUDP(DestIpAddr, 10001, 10001, txt, 4); GBP
120 flag=0;
121
122 }
BWP
123 }
124 }
You can download the full project files below. All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to
unzip files).
Author
Bitahwa Bindu
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 12/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
LOG IN WITH
OR SIGN UP WITH DISQUS ?
Name
10 Golden Rules for a Job Interview Digital Clock using PIC Microcontroller and the DS1307 Real
2 comments • 4 years ago Time Clock – XC8 Compiler
keshena — Great article indeed. Very useful. Thanks 15 comments • 4 years ago
Student Companion — In your error message you posted, it shows
PIC16F877a
Interfacing DC Motor with PIC Microcontroller – MikroC Interfacing The PCF8583 Real Time Clock With PIC
ZA R
10 comments • 3 years ago Microcontroller – MikroC
Student Companion — Yes you can use that code with PIC16F877A 7 comments • 4 years ago
but you'll have to do some minor changes. To find out what to change, Student Companion — Be specific about your question, and write it inEU R
please ask your question in … the forum, not in comments: https://www.studentcompanio...
US D
✉ Subscribe d Add Disqus to your siteAdd DisqusAdd 🔒 Disqus' Privacy PolicyPrivacy PolicyPrivacy
GBP
BWP
RELATED POSTS
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 13/14
5/19/2019 UDP Control and Monitoring with PIC Microcontroller | StudentCompanion
ZA R
EU R
US D
GBP
BWP
Privacy - Terms
https://www.studentcompanion.co.za/ethernet-udp-based-control-and-monitoring-with-pic-microcontroller-mikroc/ 14/14