代做ECET 35901 Computer Based Data Acquisition Applications Summer 2025 Practical Assignment 6调试R语言

ECET 35901

Computer Based Data Acquisition Applications

Summer 2025

[Practical Assignment 6]

Raspberry Pi GPIO in Node Red

Objectives:

• Configure the Raspberry Pi’s GPIO with Node Red.

• Familiarize with the pinout of the Raspberry Pi 4 Model B.

• Create a binary to seven segment decoder.

Hardware Requirements:

• Raspberry Pi 4 Model B (w/ Monitor, Keyboard & Mouse)

• Breadboard

• 4 Single Pole Double Throw (SPDT) Switches

• Breadboard Wires

• Common Cathode Seven Segment Display (Common Anode version is also possible)

• 330 Ω Resistors

[GPIO & Seven Segment Display]

1. Raspberry Pi GPIO:

Observe the Raspberry Pi 4 Model B Pinout below in fig. 1. There are several things that must be considered before accessing the GPIO. Note that certain pins have dual functions in addition to being a GPIO pin, for example, GPIO 10 can also be programmed to be the MOSI line in SPI communication. Also notice the locations of the power and ground pins and that there are two different supply levels: +5 V and +3.3 V. Even though there are +5V pins, the Raspberry Pi operates using the 3.3 V logic level! Don’t be confused with the GPIO numbers (0-27) and the Raspberry Pi pin numbers (1-40)!!

Figure 1 Raspberry Pi 4 Model B Pinout and Pin interfaces

We can configure these pins using Node-RED by utilizing the GPIO node library. Recall that the nodes are located on the lefthand side panel. Scroll down until you see the Raspberry Pi section, and you will see the following nodes as shown in fig. 2.

Figure 2 Raspberry Pi nodes

We will focus on the top two nodes, “rpi – gpio in” and “rpi – gpio out” ,which configure a pin as an input or output. Drag the “rpi – gpio out” node onto the workspace and double click the node. You should see a window shown in fig. 3. In this window you can select which of the GPIO pins you want to map to. Under “Type” you have an option to set the output as regular bit output (HIGH/LOW) or a PWM output. In this lab we will use the regular “Digital Output” option.

Figure 3 Raspberry Pi GPIO output properties

In later labs, to configure the pin as GPIO input modes, you must select an option for a pull-up or pull-down resistor or none. You will see the GPIO input properties shown in fig.4.

Figure 4 Raspberry Pi GPIO Input properties

2. Seven Segment Display:

Study your common cathode seven segment display’s pinout in its datasheet. The most common pinout is shown in fig. 5, but yours might be different. Also if your segment display is common anode type, the ground connection should be to Vcc.

Figure 5 Common Cathode Seven Segment Display Pinout - this can be vary by each product

Your task is to create a binary to seven segment decoder, where four switches will represent each binary bit counting up to 15 or “A” in hexadecimal. With these four bits, you must decode the resulting number to a seven segment display. For example, “0001” should decode to “1” on the seven segment display, and “1111” should decode to “F”. See table 1 for exact details.

Table 1:

Binary to Seven Segment Conversion

Binary Number                          Seven Segment Display

0000                                  “0”

0001                                   “1”

0010                                    “2”

0011                                    “3”

0100                                    “4”

0101                                    “5”

0110                                    “6”

0111                                    “7”

1000                                    “8”

1001                                     “9”

1010                                     “A”

1011                                     “B”

1100                                     “C”

1101                                     “D”

1110                                      “E”

1111                                      “F”

[Node-RED implementation]

Observe the following fig. 6. You must obtain the inputs from the switches using the GPIO nodes, then convert them into flow variables to be called in the “Binary to SS Decoder” Function. The hardware schematic using a common cathode segment display is provided in Fig. 7.

Figure 6 Node-RED implementation examples with Rasberry Pi GPIOs

Figure 7 Hardware Schematic with a common cathod segment led

From the fig.6, the “Binary to SS Decoder” function then outputs Boolean values to be sent to the output GPIO nodes. The code for “Binary to SS Decoder” is provided below for your reference (not for copy and paste). Study the code, and note the flow variable names, and make sure you match those names to the outputs of the set/switch nodes. The GPIO pins to be used as inputs and outputs you use are free for you to choose. Also, the code can be greatly simplified, again, the code is for your reference, feel free to edit the code.

// Variable Initilization var bit0 = flow.get("bit0"); var bit1 = flow.get("bit1"); var bit2 = flow.get("bit2"); var bit3 = flow.get("bit3"); var seg_a = {payload: null}; var seg_b = {payload: null}; var seg_d = {payload: null}; var msg_d = {payload: null}; var seg_e = {payload: null}; var seg_f = {payload: null}; var seg_g = {payload: null}; // Display "1" if (bit0 == true && bit1 == false && bit2 == false && bit3 == false) { seg_a = {payload: false}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: false}; seg_e = {payload: false}; seg_f = {payload: false}; seg_g = {payload: false}; } // Display "2" else if (bit0 == false && bit1 == true && bit2 == false && bit3 == false) { seg_a = {payload: true}; seg_b = {payload: true}; seg_d = {payload: false}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: false}; seg_g = {payload: true}; } // Display "3" else if (bit0 == true && bit1 == true && bit2 == false && bit3 == false) { seg_a = {payload: true}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: false}; seg_f = {payload: false}; seg_g = {payload: true}; } // Display "4" else if (bit0 == false && bit1 == false && bit2 == true && bit3 == false) { seg_a = {payload: false}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: false}; seg_e = {payload: false}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "5" else if (bit0 == true && bit1 == false && bit2 == true && bit3 == false) { seg_a = {payload: true}; seg_b = {payload: false}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: false}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "6" else if (bit0 == false && bit1 == true && bit2 == true && bit3 == false) { seg_a = {payload: true}; seg_b = {payload: false}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "7" else if (bit0 == true && bit1 == true && bit2 == true && bit3 == false) { seg_a = {payload: true}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: false}; seg_e = {payload: false}; seg_f = {payload: false}; seg_g = {payload: false}; } // Display "8" else if (bit0 == false && bit1 == false && bit2 == false && bit3 == true) { seg_a = {payload: true}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "9" else if (bit0 == true && bit1 == false && bit2 == false && bit3 == true) { seg_a = {payload: true}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: false}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "A" else if (bit0 == false && bit1 == true && bit2 == false && bit3 == true) { seg_a = {payload: true}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: false}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "B" else if (bit0 == true && bit1 == true && bit2 == false && bit3 == true) { seg_a = {payload: false}; seg_b = {payload: false}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "C" else if (bit0 == false && bit1 == false && bit2 == true && bit3 == true) { seg_a = {payload: true}; seg_b = {payload: false}; seg_d = {payload: false}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: false}; } // Display "D" else if (bit0 == true && bit1 == false && bit2 == true && bit3 == true) { seg_a = {payload: false}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: false}; seg_g = {payload: true}; } // Display "E" else if (bit0 == false && bit1 == true && bit2 == true && bit3 == true) { seg_a = {payload: true}; seg_b = {payload: false}; seg_d = {payload: false}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "F" else if (bit0 == true && bit1 == true && bit2 == true && bit3 == true) { seg_a = {payload: true}; seg_b = {payload: false}; seg_d = {payload: false}; msg_d = {payload: false}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: true}; } // Display "0" else { seg_a = {payload: true}; seg_b = {payload: true}; seg_d = {payload: true}; msg_d = {payload: true}; seg_e = {payload: true}; seg_f = {payload: true}; seg_g = {payload: false}; } return [seg_a, seg_b, seg_d, msg_d, seg_e, seg_f, seg_g];

Note that the power and ground lines are from the Raspberry Pi's outputs; you do not need external power supplies for your circuit.

Below (fig.8) segment display’s schematic and connections are for the common anode type. Observe the common anode connection – the connected resister values can vary, typically 200-500Ω.

Figure 8 Common anode segment display connections and pinouts

[Submission]

Once you complete the flow,

1. Export it as a .JSON file and submit the file in the Brightspace assignment folder.

2. Make a short video (50sec ~1min) to demonstrate the functionality. Just provide the video link for me to check (do not upload the video to Brightspace directly, otherwise some penalty will apply).




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图