Hi I am really struggling with this lab and would really appreciate the help as aspects of this lab are crucuial form my

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hi I am really struggling with this lab and would really appreciate the help as aspects of this lab are crucuial form my

Post by answerhappygod »

Hi I am really struggling with this lab and would really
appreciate the help as aspects of this lab are crucuial form my
assessment.
This task involves an Arduino uno with an ATMega328P chip, as
well as the shield that is mentioned in the picture below. As
stated the shield has 2 serial to parallel converter chips
connected to the 7 segment display. The code is written on MPLAB X
IDE.
I think I understand how the converter chips work with the
ATMega, but am not entirely sure. Most importantly though, I'm a
bit stuck on the coding aspect of it.
I've added a picture of the code which it asks us to modify. We
supposedly only need to add the code for void sendData(uint8_t
segments, uint8_t digits), but I have been trying based of my
understanding pf the hardware but I can't get it to work.
I have here a post that my lecturer made regarding the lab:
"For students who have started looking at this weeks' practical,
the framework file for Part 1 is: 22S1_ELEC3042_L3P1_7_segment.c.
In that file, you will need to write the code for the sendData()
function. You should study the MC74HC595 datasheet and the HW-262
schematic to see how everything is connected and what the MC74HC595
is supposed to do. Once you have understood this, you should
realize that the sendData() function should serially shift 16 bits
of data out of PB0 using PD7 as the clock signal. When all 16 bits
are sent, you then latch it to the output using PD4. "
Hi I Am Really Struggling With This Lab And Would Really Appreciate The Help As Aspects Of This Lab Are Crucuial Form My 1
Hi I Am Really Struggling With This Lab And Would Really Appreciate The Help As Aspects Of This Lab Are Crucuial Form My 1 (420.45 KiB) Viewed 27 times
Part 1: 7 Segment Displays Introduction The HW-262 shield has 4 seven segment displays on board. These are controlled by two 74HC595 serial to parallel converter chips. The '595 chips are controlled by Arduino pins as shown below. Arduino Pin Function Serial Data to '595 ATmega328 port ID PBO 74HC595 pin 14 D8 D7 PD7 11 Shift Clock Latch Clock D4 PD4 12 A partial schematic is given below. U1 12 8888 नंनं 6 सरी D4 PO4 P25 વૈ941-4-11-11 99888888888 1888888888 U3 MC74HC595AD IL SFICLK OD 4 12 ICHCLK BE MC74HC595 AD YDD 1 4 SDI 1SFICLK QA 12. ICHCLK QB OE GND PI It can be seen that the display is controlled by 16 bits sent out through PBO, clocked by the rising edge of PD7, and finally latched by the rising edge of PD4. Read the data sheet for the '595 chip to understand how these signals interact. A framework for a program to send the 16 bits of data is provided on ilearn.
Modify the 2251_ELEC3042_L3P1_7_segment.c program so that it transmits the data to the “595 chips and can display the data sent. You will note that the data sent to the segments is which segment to turn on or off, not the digit to display. We will map between the digit to display and the binary data of each digit. We have extended the framework to provide this mapping.
#include <xc.h> void delay_ms(long num) { while (num--) { for (volatile long x = 0; X < 468; x++) { ; } } } // set up data direction registers for the output pins void setup() { DDRD = 0010010000; PORTD = Ob00000000; DDRB = Ob00000001; PORTB = Ob00000000; } // send the 8 bits of data in segments (top bit first) // then the 8 bits of data in digits (top bit first) void sendData(uint8_t segments, uint8_t digits) { // TODO: write the 16 bits of data using PD4 and PD7 then clock it to the output using PBO } const uint8_t SEGMENT_MAP[] = { Oxco, oxF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0X80, ox90, 0x88, 0x83, 0xC6, OxA1, 0x86, 0x8E, OxFF, OxBF}; // digits 0-9 // digits A-F // blank, dash uint8_t segmentMap(uint8_t value) { return SEGMENT_MAP[value]; } int main(void) { setup(); // set up the physical hardware int delay = 30; while (1) { // display all combinations of lit segments for each digit for (int i = 0; i < 4; i++) { for (int count = 0; count < 256; count++) { sendData((uint8_t)count, (1 « i)); delay_ms(delay); } } } }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply