Jump to content

lukelouyu

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by lukelouyu

  1. Add "/r/n" in sprintf((char*)command, "GET https://api.thingspeak.com/channels/"ThingSpeak_Channel_Num"/fields/1.json?results=1" );
  2. Hi, I have been trying to use the zybo board timer interrupt functions to control my water pump while running other program, kind of like multitasking. The program goes like this, when the my other programs are running in the while(true) loop (running forever), the water pump will turn on for 12 hours and turn off for 12 hours. Before jumping into actual program, I made some simple testing. While the Pmod HYGRO is getting value, the led 4bits will have a loop of turning on for 100s and turning off 100s (like led toggling) Here is what I have tried with built-in led: #include <stdio.h> #include "platform.h" #include "xil_printf.h" #include "xparameters.h"; #include "xgpio.h"; #include "xtmrctr.h"; #include "xscugic.h"; #include "xil_exception.h"; #include "PmodHYGRO.h" #include "sleep.h" #include "xil_cache.h" #ifdef __MICROBLAZE__ #define TIMER_FREQ_HZ XPAR_CPU_M_AXI_DP_FREQ_HZ #else #define TIMER_FREQ_HZ 100000000 #endif PmodHYGRO myDevice; void DemoInitialize(); void DemoRun(); void DemoCleanup(); void EnableCaches(); void DisableCaches(); // Parameter definitions #define INTC_DEVICE_ID XPAR_PS7_SCUGIC_0_DEVICE_ID #define TMR_DEVICE_ID XPAR_TMRCTR_0_DEVICE_ID #define LEDS_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID #define INTC_TMR_INTERRUPT_ID XPAR_FABRIC_AXI_TIMER_0_INTERRUPT_INTR #define TMR_LOAD 0xF8000000 XGpio LEDInst; XScuGic INTCInst; XTmrCtr TMRInst; static int led_data; static int tmr_count; //void print (char *str); static void TMR_Intr_Handler(void *baseaddr_p); static int IntcInitFunction (u16 DeviceId, XTmrCtr *TmrInstancePtr); void TMR_Intr_Handler(void *data){ if (XTmrCtr_IsExpired(&TMRInst,0)){ // Once timer has expired 3 times, stop, increase counter //reset timer and start running again if(tmr_count==3){ XTmrCtr_Stop(&TMRInst,0); tmr_count=0; //led_data++; led_data=~led_data; XGpio_DiscreteWrite(&LEDInst,1,led_data); XTmrCtr_Reset(&TMRInst,0); XTmrCtr_Start(&TMRInst,0); }else tmr_count++; } } // Initial Setup Functions int InterruptSystemSetup(XScuGic *XScuGicInstancePtr){ // Enable Interrupt Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler) XScuGic_InterruptHandler, XScuGicInstancePtr); Xil_ExceptionEnable(); return XST_SUCCESS; } int IntcInitFunction (u16 DeviceId, XTmrCtr *TmrInstancePtr){ XScuGic_Config *IntcConfig; int status; //Interrupt controller initialisation IntcConfig=XScuGic_LookupConfig(DeviceId); status= XScuGic_CfgInitialize(&INTCInst, IntcConfig, IntcConfig->CpuBaseAddress); if (status!= XST_SUCCESS) return XST_FAILURE; //Call to interrupt setup status= InterruptSystemSetup(&INTCInst); if (status != XST_SUCCESS) return XST_FAILURE; // Connect timer interrupt to handler status= XScuGic_Connect(&INTCInst, INTC_TMR_INTERRUPT_ID, (Xil_ExceptionHandler) TMR_Intr_Handler, (void*) TmrInstancePtr); if (status != XST_SUCCESS) return XST_FAILURE; // Enable timer interrupts in the controller XScuGic_Enable(&INTCInst, INTC_TMR_INTERRUPT_ID); return XST_SUCCESS; } int main() { init_platform(); led_data=0; int status; // INITIALISE THE PERIPHERALS & SET DIRECTIONS OF GPIO // Initialise LEDs status=XGpio_Initialize(&LEDInst, LEDS_DEVICE_ID); ; if (status != XST_SUCCESS) return XST_FAILURE; // Set LEDs direction to outputs XGpio_SetDataDirection(&LEDInst, 1,0x00); //Initilise interrupt controller status=IntcInitFunction(INTC_DEVICE_ID, &TMRInst); if (status != XST_SUCCESS) return XST_FAILURE; // Set the TIMER status= XTmrCtr_Initialize(&TMRInst, TMR_DEVICE_ID); if (status != XST_SUCCESS) return XST_FAILURE; XTmrCtr_SetHandler(&TMRInst, (XTmrCtr_Handler) TMR_Intr_Handler, &TMRInst); XTmrCtr_SetResetValue(&TMRInst,0,TMR_LOAD); XTmrCtr_SetOptions(&TMRInst,0, XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION); XTmrCtr_Start(&TMRInst,0); while(1) DemoInitialize(); DemoRun(); DemoCleanup(); return 0; } void DemoInitialize() { EnableCaches(); xil_printf("Init Started\n\r"); HYGRO_begin( &myDevice, XPAR_PMODHYGRO_0_AXI_LITE_IIC_BASEADDR, 0x40, // Chip address of PmodHYGRO IIC XPAR_PMODHYGRO_0_AXI_LITE_TMR_BASEADDR, XPAR_PMODHYGRO_0_DEVICE_ID, TIMER_FREQ_HZ // Clock frequency of AXI bus, used to convert timer data ); xil_printf("Init Done\n\r"); } void DemoCleanup() { DisableCaches(); } void DemoRun() { float temp_degc, hum_perrh, temp_degf; while (1) { temp_degc = HYGRO_getTemperature(&myDevice); temp_degf = HYGRO_tempC2F(temp_degc); hum_perrh = HYGRO_getHumidity(&myDevice); xil_printf( "Temperature: %d.%02d deg F Humidity: %d.%02d RH\n\r", (int) temp_degf, ((int) (temp_degf * 100)) % 100, (int) hum_perrh, ((int) (hum_perrh * 100)) % 100 ); // %f does not work with xil_printf // instead, converting float to a pair of ints to display %.2f. // 1 sample per second maximum, as per 9.2.1 in HDC1080 reference manual sleep(1); } } void EnableCaches() { #ifdef __MICROBLAZE__ #ifdef XPAR_MICROBLAZE_USE_ICACHE Xil_ICacheEnable(); #endif #ifdef XPAR_MICROBLAZE_USE_DCACHE Xil_DCacheEnable(); #endif #endif } void DisableCaches() { #ifdef __MICROBLAZE__ #ifdef XPAR_MICROBLAZE_USE_ICACHE Xil_ICacheDisable(); #endif #ifdef XPAR_MICROBLAZE_USE_DCACHE Xil_DCacheDisable(); #endif #endif } Here is Vivado block diagram: Here are some issues faced: 1) when i change value in "if(tmr_count==3)" to a large value, the time of toggling is still within 3s. (if there is no HYGRO code) 2) the led does not function, but the HYGRO functions when there is code for HYGRO If anyone can also help me or give me suggestion on water pump timer control, I will be so much appreciate it. I will upload my Vivado block design and Vitis code below for your reference. Thanks Luke Louyu. New Code V1.0.txt
  3. @zygot I am currently using DF robot gravity EC sensor and pH sensors Here are the links for these two sensors: https://www.dfrobot.com/product-1123.html (EC sensor) https://www.dfrobot.com/product-1782.html (pH sensor) Here are design specification: Thanks Luke
  4. @JColvin Thanks. Btw, I also changed the ref voltage to 1.8 and get this information.
  5. @Niță Eduard Thanks for your answer, I did not use the external power supply. I try to fix this issue by restarting my laptop.
  6. Hi, everyone here. Now, I have tried with my Pmod AD1. I used the demo code provided by the Digilent, but the value shown in the Vitis Serial Terminal is different from the value I have seen in the multimeter. For example, when I insert my sensor A into the channel A0, the value shown in 2.56. The value shown in the multimeter is 2.9V. When I insert my sensor B into the channel A1, the value shown in the Vitis Serial Terminal is 1.08. The value shown in the multimeter is about 2.1V. When the sensor induced voltage exceeds 1.8V, the AD1 value returns back to 0. I think this diagram might tell me the reason. But I am not sure since I am new to FPGA & electronic and I don't quite understand the datasheet. (Link: https://www.analog.com/media/cn/technical-documentation/evaluation-documentation/AD7476A_7477A_7478A.pdf?_ga=2.196220652.1995249494.1621070558-1887244704.1616928603) Through comparing with the AD1 reading voltage and the multimeter voltage, i found there is an linear relationship between them. I made an excel file to show you guys the relationship. I suspected i need to add an additional voltage source but not sure as well. When I connects the Vcc to the D0 or D1, the serial terminal said 3.3V. I did not change anything in the demo code, is there anyway to allow the AD1 reading to be the same as the reading in the multimeter. Thanks Luke
  7. @efkean @JColvin Today, I tried with my Pmod AD1. However, the value shown in the Vitis Serial Terminal is lower than the value shown in my multimeter. Do I need to change the demo code in order to fix this issue?
  8. hi, I have been facing issue and I want to figure out what type of reasons can cause it? Connection issue? Or sth else? For installing my program into the zybo board, it sometimes works while sometimes pop up this error message. Like intermittently working. Here are some error message: targets -set -filter {jtag_cable_name =~ "Digilent Zybo Z7 210351AD668FA" && level==0} -index 1 fpga -file C:/Users/lukel/workspace8/test_3/_ide/bitstream/design_7_wrapper.bit targets -set -nocase -filter {name =~"APU*"} loadhw -hw C:/Users/lukel/workspace8/design_7_wrapper/export/design_7_wrapper/hw/design_7_wrapper.xsa -mem-ranges [list {0x40000000 0xbfffffff}] configparams force-mem-access 1 targets -set -nocase -filter {name =~"APU*"} source C:/Users/lukel/workspace8/test_3/_ide/psinit/ps7_init.tcl ps7_init ----------------End of Script---------------- 15:56:02 ERROR : Memory read error at 0xF8006050. Invalid DAP IDCODE. Invalid DAP ACK value: 0 Thanks Luke
  9. @JColvin Thanks so much for your help. I can generate my bistream and export my xsa file into Vitis. I run my sample xadc code and it works! Now, I also can manage to upload my pH data into Thingspeak. Now, it is some small issue of inaccurate sensor result, but that is not about the fpga issue.
  10. Hi, @JColvin Thanks you for answer me the question. In actually, I have done the similar block design with the block design you have sent to me. It can successfully generated the bistream, but when I insert my xadc code into the Vitis, let my zybo board to run the program and connect my pH sensor to the zybo baord, the zybo board cannot sense the induced voltage of the sensor. (I think the reason is I never make my xadc vaux14 and vaux7 to external. when I make these two to external, my zybo board can sense the voltage). Regarding to the question you asked me, I never use the xadc file for the block diagram. For xadc part, i used this tutorial (actually it is from another post in the FPGA forum) as guide. This tutorial does not need to use the xdc file. My pH sensor and EC sensor works in this diagram. ( I received the induced voltage from the sensor, after that I compared the pH value in Arduino and the induced voltage shown in Vitis Serial Terminal and get the formula to convert the induced voltage to the real pH value) From here, i try to add another sensors like Pmod ESP32 and Pmod ALS etc, so that I can upload my pH sensor data to the Thingspeak. I will also provide you with the Vitis C code for xadc portion. Xadc Code.txt I also realized this issue after I troubleshoot this block diagram. I am not sure if I can use this function to allow me generating the bistream sucessfully. In actually, I am also considering to use Pmod AD1 as a substitution to the built-in XADC since I can generate bistream with Pmod AD1 and Pmod ESP32. However, i need to wait for few days to receive my pmod ad1. If you are okay, can you give me some suggestions on pmod ad1 as well. Thanks Luke
  11. @JColvin Thanks for your answer. The error is implementation error. I can see that the difference between your block diagram and my block diagram is I add the external port for Vp_vn, Vaux7 and Vaux 14. And I set up 100MHz frequency for the Pmod ESP32. For set up, I connect my analog pH sensor signal pin into the the voltage regulating circuit. Then, I make a connection between the Zybo port Port A AD14 and the end side of the voltage regulating circuit. If I only insert the xadc wizard into the block diagram, the bitstream can be generated and I can receive the induced voltage of the sensor. Through setting the formula in the Vitis, I can get the pH value from my sensor. Now, I want to upload my sensor value to the thingspeak. Previously, I have uploaded the temperature value, humidity value, ambient light value and carbon dioxide value into the thingspeak. If this problem solve, I can see all the value i needed in the thingspeak. I will show you some of the work I have done before this problem occured. This is how I set up for my xadc This is how I set up for other Pmod sensor. The implementation error occurred when I tried to integrate these two things together. Here is error message [Place 30-372] Bank 35 has terminals with incompatible standards: Incompatible Pair of IO Standards: (IN of IO Standard LVCMOS18) & (INOUT of IO Standard LVCMOS33) have incompatible Vccs The following terminals correspond to these IO Standards: SioStd: LVCMOS18 VCCO = 1.8 Termination: 0 TermDir: In Bank: 35 Placed : Term: Vaux14_0_v_n Term: Vaux14_0_v_p Term: Vaux7_0_v_n Term: Vaux7_0_v_p SioStd: LVCMOS33 VCCO = 3.3 Termination: 0 TermDir: BiDi Bank: 35 Drv: 12 Placed : Term: je_pin3_io Term: and je_pin4_io [Place 30-374] IO placer failed to find a solution Below is the partial placement that can be analyzed to see if any constraint modifications will make the IO placement problem easier to solve. +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | IO Placement : Bank Stats | +----+-------+-------+------------------------------------------------------------------------+------------------------------------------+--------+--------+--------+-----+ | Id | Pins | Terms | Standards | IDelayCtrls | VREF | VCCO | VR | DCI | +----+-------+-------+------------------------------------------------------------------------+------------------------------------------+--------+--------+--------+-----+ | 0 | 0 | 0 | | | | | | | | 13 | 25 | 8 | LVCMOS33(8) | | | +3.30 | YES | | | 34 | 50 | 22 | LVCMOS33(22) | | | +3.30 | YES | | | 35 | 50 | 6 | LVCMOS18(4) LVCMOS33(2) | | | +3.30 | YES | | +----+-------+-------+------------------------------------------------------------------------+------------------------------------------+--------+--------+--------+-----+ | | 125 | 36 | | | | | | | +----+-------+-------+------------------------------------------------------------------------+------------------------------------------+--------+--------+--------+-----+ IO Placement: +--------+----------------------+-----------------+----------------------+----------------------+----------------------+ | BankId | Terminal | Standard | Site | Pin | Attributes | +--------+----------------------+-----------------+----------------------+----------------------+----------------------+ | 13 | jb_pin10_io | LVCMOS33 | IOB_X0Y5 | W6 | | | | jb_pin1_io | LVCMOS33 | IOB_X0Y20 | V8 | | | | jb_pin2_io | LVCMOS33 | IOB_X0Y19 | W8 | | | | jb_pin3_io | LVCMOS33 | IOB_X0Y28 | U7 | | | | jb_pin4_io | LVCMOS33 | IOB_X0Y27 | V7 | | | | jb_pin7_io | LVCMOS33 | IOB_X0Y24 | Y7 | | | | jb_pin8_io | LVCMOS33 | IOB_X0Y23 | Y6 | | | | jb_pin9_io | LVCMOS33 | IOB_X0Y6 | V6 | | +--------+----------------------+-----------------+----------------------+----------------------+----------------------+ | 34 | jc_pin10_io | LVCMOS33 | IOB_X1Y95 | U12 | | | | jc_pin1_io | LVCMOS33 | IOB_X1Y80 | V15 | | | | jc_pin2_io | LVCMOS33 | IOB_X1Y79 | W15 | | | | jc_pin3_io | LVCMOS33 | IOB_X1Y98 | T11 | | | | jc_pin4_io | LVCMOS33 | IOB_X1Y97 | T10 | | | | jc_pin7_io | LVCMOS33 | IOB_X1Y84 | W14 | | | | jc_pin8_io | LVCMOS33 | IOB_X1Y83 | Y14 | | | | jc_pin9_io | LVCMOS33 | IOB_X1Y96 | T12 | | | | jd_pin10_io | LVCMOS33 | IOB_X1Y57 | V18 | | | | jd_pin1_io | LVCMOS33 | IOB_X1Y90 | T14 | | | | jd_pin2_io | LVCMOS33 | IOB_X1Y89 | T15 | | | | jd_pin3_io | LVCMOS33 | IOB_X1Y88 | P14 | | | | jd_pin4_io | LVCMOS33 | IOB_X1Y87 | R14 | * | | | jd_pin7_io | LVCMOS33 | IOB_X1Y78 | U14 | | | | jd_pin8_io | LVCMOS33 | IOB_X1Y77 | U15 | | | | jd_pin9_io | LVCMOS33 | IOB_X1Y58 | V17 | | | | je_pin10_io | LVCMOS33 | IOB_X1Y85 | Y17 | | | | je_pin1_io | LVCMOS33 | IOB_X1Y92 | V12 | | | | je_pin2_io | LVCMOS33 | IOB_X1Y63 | W16 | | | | je_pin7_io | LVCMOS33 | IOB_X1Y93 | V13 | | | | je_pin8_io | LVCMOS33 | IOB_X1Y81 | U17 | | | | je_pin9_io | LVCMOS33 | IOB_X1Y60 | T17 | | +--------+----------------------+-----------------+----------------------+----------------------+----------------------+ | 35 | Vaux14_0_v_n | LVCMOS18 | IOB_X1Y107 | N16 | | | | Vaux14_0_v_p | LVCMOS18 | IOB_X1Y108 | N15 | | | | Vaux7_0_v_n | LVCMOS18 | IOB_X1Y105 | L15 | | | | Vaux7_0_v_p | LVCMOS18 | IOB_X1Y106 | L14 | | | | je_pin3_io | LVCMOS33 | IOB_X1Y100 | J15 | | | | je_pin4_io | LVCMOS33 | IOB_X1Y112 | H15 | | +--------+----------------------+-----------------+----------------------+----------------------+----------------------+ [Place 30-99] Placer failed with error: 'IO Clock Placer failed' Please review all ERROR, CRITICAL WARNING, and WARNING messages during placement to understand the cause for failure. [Common 17-69] Command failed: Placer could not place all instances Thanks Luke
  12. I have tried to use built-in xadc to acquire the analog sensor value. Now, I want to send my data from my analog sensor and other Pmod sensors to thingspeak through using Pmod ESP32. Here I find some trouble. In block design, there is always an implementation error. However, if I drop the ESP32 away from the block design, I can generate the bitstream, export to Vitis and get all the data in Vitis serial terminal. Next, I tried to integrate only the sensor and esp32 into one block design, it failed again. I will show you the screenshot below for better illustration. I suspected the reason is the clock frequency and processor system reset. I hope any vivado genius can help my problem
  13. I think based on my understanding, I should draw my block diagram in this way. I connect the AQS to JC port and connect the J2 of the aqs to the J1 of the hygro.
  14. Thanks so much. Maybe I confuse with meaning of "daisy chain". But what i am worry is how to configurate this into Vivado block design, as well as the coding part when the xsa file in vivado exports to Vitis IDE. Should I use the IP core of AQS and HYGRO for block design? Or Should I use the AXI IIC only? My intern supervisor told me that for port JF i may not need IP Core. But JB to JE need IP core. I am worried that if it works only when it places on JF port because I need to use JF port for my LED and Water pump control. Sorry that I am new to FPGA and still catching up with some fundamental knowledges.
  15. I am currently doing the vertical farming project. And I want to put my Pmod HYGRO and Pmod AQS sensor into the same port JC. I have tried to put my Pmod HYGRO and Pmod AQS into different Pmod ports successfully. Now, I just want to combine these two sensors into one port. For example, for port JC. I want the top layer of the port connect to Pmod AQS and the bottom layer of the port to the Pmod HYGRO. So what is my first step to do when comes to vivado block design and how am I going to write my Cpp code into Vitis IDE? I did some primary research on this topic before. I may need to use AXI IIC or something else. Is that true? Also, if using AXI IIC, how am I going to connect the Pmod to the AXI IIC and connect the specific pin of Pmod to the specific pin of the port? Thanks in advance. Below is my vivado block design so far?
  16. By the way, I have already tried to use two different port to connect two different Pmod sensors like few days ago.
  17. I am thinking if I can connect the specific pin in the port JC with specifc pin in the Pmod HYGRO or Pmod AQS? Maybe from PmodOut. I am not so sure?
  18. Thanks so much for your long explanation. May I ask can your one works for JC connection? I don't want to use JE. And I realise that JE and JC are different type of port. I am currently doing the vertical farming project and I want the JE to be used for relay to control the LED and water pump. Now, I may give up on IOXP and use the first layer of JC port for AQS connection and second layer of JC port for HYGRO connection.
  19. ALSO, for this part Edit: Actually from what I can see you can daisy chain the PmodHYGRO and the PmodAQS by connecting one into the other without needing additional connectors/cables since their SDA and SCL pinout match perfectly. Will it affect the block design in Vivado and Vitis as well?
  20. This is how I draw the block design, I don't know how to connect the AQS and HYGRO IP core into AXI IIC. Is it like pin3 (SCL) of the AQS/HYGRO connect to scl_i/scl_o/scl_t and pin 4 of the AQS/HYGRO connect to sda_i/sda_o/sda_t? Any connection for AXI_LITE_TMR (HYGRO) and AXI_LITE_IIC (HYGRO & AQS)? And is the iic_rtl already represents the connector JC? I have written set_property -dict { PACKAGE_PIN T11 IOSTANDARD LVCMOS33 } [get_ports { iic_rtl_scl_io }]; #IO_L1P_T0_34 Sch=jc_p[2] set_property -dict { PACKAGE_PIN T10 IOSTANDARD LVCMOS33 } [get_ports { iic_rtl_sda_io }]; #IO_L1N_T0_34 Sch=jc_n[2] into my newly-added ZYBO master xdc file.
  21. Thanks for your answer. So is there is a way to connect the Pmod HYGRO and Pmod AQS into the same high-speed Pmod port without using PmodIOXP or the simplest way to achieve this function? If yes, how am I going to do a block design in Vivado. I will continue to figure out the possibility of using PmodIOXP to achieve the result I want.
  22. Also, I don't understand what do you mean by "constraining their input/output interface to a Pmod port of your choice on your board according to this pinout"
  23. So do you mean that i connect AXI IIC and other two Pmod sensors according to the pinout. And How am I going to connect two Pmod sensors to connector JC?
  24. I want to use PmodIOXP to allow both PmodAQS and PmodHYGRO to be connected into the same port in Zybo Z720. However, I do not know how to write my block design in Vivado since there is no IP for PmodIOXP in the vivado-library. Also, what kind of C++ code should I write in my Vitis after I exported my vivado file into Vitis
×
×
  • Create New...