From 3bf16287b1e18838d0a0d3c1b2f400263c2d3048 Mon Sep 17 00:00:00 2001 From: Oscar <25309418+osw282@users.noreply.github.com> Date: Fri, 16 Aug 2024 10:47:16 +0100 Subject: [PATCH] Pretty print the output (#6) * Pretty print the output * Final --- .../experiment_rag_retrieval_rerank.ipynb | 380 +++++++++++++++--- 1 file changed, 316 insertions(+), 64 deletions(-) diff --git a/rag_retrieval_rerank/experiment_rag_retrieval_rerank.ipynb b/rag_retrieval_rerank/experiment_rag_retrieval_rerank.ipynb index 9a3c4b9..cd7eae3 100644 --- a/rag_retrieval_rerank/experiment_rag_retrieval_rerank.ipynb +++ b/rag_retrieval_rerank/experiment_rag_retrieval_rerank.ipynb @@ -31,7 +31,7 @@ "\n", "Specifically, we are looking for following content in the retrieved documents.\n", "\n", - "`In this chapter, many programs were developed using the NUCLEO board, provided with the STM32F429ZIT6U microcontroller. This microcontroller is manufactured by STMicroelectronics [13] using a Cortex-M4 processor designed by Arm Ltd. [14].`" + "`This microcontroller is manufactured by STMicroelectronics`" ] }, { @@ -110,8 +110,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 2min 42s, sys: 3.93 s, total: 2min 46s\n", - "Wall time: 3min 6s\n" + "CPU times: user 2min 31s, sys: 2.88 s, total: 2min 34s\n", + "Wall time: 2min 46s\n" ] } ], @@ -162,8 +162,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 51min 30s, sys: 3min 50s, total: 55min 20s\n", - "Wall time: 15min 4s\n" + "CPU times: user 46min 26s, sys: 2min 41s, total: 49min 8s\n", + "Wall time: 12min 45s\n" ] } ], @@ -451,7 +451,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 17/17 [00:11<00:00, 1.50it/s]\n" + "100%|██████████| 17/17 [00:12<00:00, 1.33it/s]\n" ] } ], @@ -487,7 +487,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -498,7 +498,7 @@ " res = index.query(vector=encoded_query[0], top_k=top_k, include_metadata=True)\n", " # get doc text\n", " closest_texts = [(match[\"metadata\"]['texts'], match[\"score\"]) for match in res[\"matches\"]]\n", - " return closest_texts" + " return closest_texts # [(Retrieved Texts, Distance Score )]" ] }, { @@ -516,7 +516,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -525,7 +525,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 51, "metadata": {}, "outputs": [ { @@ -550,24 +550,24 @@ " \n", " \n", " Retrieved Document\n", - " Score\n", + " Similarity Score\n", " \n", " \n", " \n", " \n", " 0\n", " Index\\n567 STM 32F429 ZIT 6U microcontroller 5, 33, 37, 38 \\n stop bit 46, 64, 65, 80, 256 , 257 , 273 , 468 \\n ST Zio connectors xiv, 6, 9, 37, 38, 44, 346 \\n superloop 13, 519 \\n synchronous communication 255\\nT TCP server 456 , 457 , 459 , 460 –463 , 491 \\n temperature sensor 4, 5, 87, 106 , 123 , 182 , 220 , 233 , 334 , 486 , 550 \\n time management xvi, 86, 95, 99, 289 , 342 , 348 , 353 \\n timers xvi, xxvii, 37, 306 , 342 , 343 , 345 , 348 –350 , 353 , 354 , \\n 361 , 441 , 512 –517 , 533 , 535 , 537 , 538 , 539 \\n tm structure 153 \\n TO- 220 package 89\\nU UART xvi, xvii, 5, 44, 61, 63, 79, 82, 84, 86, 181 , 191 , 222 , 255 , 290 , 291 , \\n 306 , 350 , 420 , 423 , 447 , 455 , 461 , 465 , 468 , 544 \\n USB xiv, xxvii, 4, 9, 37, 44, 45, 63, 79, 82, 88, 132 , 449 , 506 , 507 , 508 , 544 \\n USB connection xiv, 44, 506 \\n use cases 497 , 501 –504 , 511 , 545 , 546 , 547 , 548\\nV validation 496 , 497 , 546 , 547 \\n verification 81, 92, 496 , 497 , 546 \\n vineyard frost prevention 123 , 124\n", - " 0.824654\n", + " 0.824475\n", " \n", " \n", " 1\n", " Chapter 1 | Introduction to Embedded Systems \\n37The STM32F429ZIT6U microcontroller includes a Cortex-M4 processor , as shown in Figure 1.22. It \\ncan be appreciated that, beyond the processor, the microcontroller includes other peripherals such as \\ncommunication cores (ethernet, USB, UART, etc.), memory, timers, and GPIO (General Purpose Input Output) ports. \\nNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK\n", - " 0.808520\n", + " 0.808997\n", " \n", " \n", " 2\n", " USAR Tn\\nbxCANnsmcard\\nirDA\\nFIFODigital\\nfilter\\nDACnAPB1 45 MHz (max)AHB1 180 MHzAHB3\\nVDD = 1.8 to 3.6V\\nVSS\\nVCAP1, VCAP2APB2 90 MHzART\\nACCEL/CACHE\\nGPIO POR TtOSC32_I N\\nOSC32_OUTDMA2USB\\nOTG HS\\n8 Streams\\nFIFODMA/\\nFIFO PHY\\nCHROM-AR T\\nDMA2DFIFO\\nFIFO8 Streams\\nFIFODMA1\\nLCD_R[7:0], LCD_G[7:0] ,\\nLCD_B[7:0], LCD_HSYNC,\\nLCD_VSYNC, LCD_DE,\\nLCD_CLKLCD-TFTDMA/\\nFIFO\\nRTC_AF1\\nRTC_AF1\\nRTC 50Hz\\n4KB BXPSRAMLS@ VBAT\\nRTC\\nAWU\\nBackup registerXTAL32 KHz\\nLSStandby\\ninterfaceIWDGXTALOSC 4-26 MHzPOR\\nreset\\nInt\\n@ VDDA @ VDDPVDPOR/PDR BORSupply\\nsupervision@ VDDVDD\\nVoltage regulator\\n3.3 to 1.2VPower\\nmanagement\\nPLL1, 2, 3RC LSRC HS@ VDDA\\nReset\\n& clock\\ncontrol\\nFigure 1.22 STM32F429ZI block diagram made using information available from [9].\n", - " 0.807650\n", + " 0.807932\n", " \n", " \n", "\n", @@ -579,20 +579,20 @@ "1 Chapter 1 | Introduction to Embedded Systems \\n37The STM32F429ZIT6U microcontroller includes a Cortex-M4 processor , as shown in Figure 1.22. It \\ncan be appreciated that, beyond the processor, the microcontroller includes other peripherals such as \\ncommunication cores (ethernet, USB, UART, etc.), memory, timers, and GPIO (General Purpose Input Output) ports. \\nNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK \n", "2 USAR Tn\\nbxCANnsmcard\\nirDA\\nFIFODigital\\nfilter\\nDACnAPB1 45 MHz (max)AHB1 180 MHzAHB3\\nVDD = 1.8 to 3.6V\\nVSS\\nVCAP1, VCAP2APB2 90 MHzART\\nACCEL/CACHE\\nGPIO POR TtOSC32_I N\\nOSC32_OUTDMA2USB\\nOTG HS\\n8 Streams\\nFIFODMA/\\nFIFO PHY\\nCHROM-AR T\\nDMA2DFIFO\\nFIFO8 Streams\\nFIFODMA1\\nLCD_R[7:0], LCD_G[7:0] ,\\nLCD_B[7:0], LCD_HSYNC,\\nLCD_VSYNC, LCD_DE,\\nLCD_CLKLCD-TFTDMA/\\nFIFO\\nRTC_AF1\\nRTC_AF1\\nRTC 50Hz\\n4KB BXPSRAMLS@ VBAT\\nRTC\\nAWU\\nBackup registerXTAL32 KHz\\nLSStandby\\ninterfaceIWDGXTALOSC 4-26 MHzPOR\\nreset\\nInt\\n@ VDDA @ VDDPVDPOR/PDR BORSupply\\nsupervision@ VDDVDD\\nVoltage regulator\\n3.3 to 1.2VPower\\nmanagement\\nPLL1, 2, 3RC LSRC HS@ VDDA\\nReset\\n& clock\\ncontrol\\nFigure 1.22 STM32F429ZI block diagram made using information available from [9]. \n", "\n", - " Score \n", - "0 0.824654 \n", - "1 0.808520 \n", - "2 0.807650 " + " Similarity Score \n", + "0 0.824475 \n", + "1 0.808997 \n", + "2 0.807932 " ] }, - "execution_count": 46, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.set_option('display.max_colwidth', None)\n", - "three_closest_texts_df = pd.DataFrame(three_closest_texts, columns=[\"Retrieved Document\", \"Score\"])\n", + "three_closest_texts_df = pd.DataFrame(three_closest_texts, columns=[\"Retrieved Document\", \"Similarity Score\"])\n", "three_closest_texts_df" ] }, @@ -603,7 +603,7 @@ "### Result\n", "The goal here is to verify if following context is present in any of the retrieved documents.\n", "\n", - "> In this chapter, many programs were developed using the NUCLEO board, provided with the STM32F429ZIT6U microcontroller. This microcontroller is manufactured by STMicroelectronics [13] using a Cortex-M4 processor designed by Arm Ltd. [14].\n", + "> This microcontroller is manufactured by STMicroelectronics.\n", "\n", "If it is present then our retrieval approach was able to find the correct document from the vector store.\n", "> It is not present in the any of retrieved documents." @@ -626,7 +626,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 52, "metadata": {}, "outputs": [], "source": [ @@ -634,14 +634,14 @@ "reranker = FlagReranker('BAAI/bge-reranker-large', use_fp16=True) # Setting use_fp16 to True speeds up computation with a slight performance degradation\n", "\n", "\n", - "def get_top_3_texts_from_rerank_scores(scores: list[float], closest_texts: list[str], top_k: int) -> list[str]:\n", + "def get_top_k_texts_from_rerank_scores(scores: list[float], closest_texts: list[str], top_k: int) -> list[str]:\n", " top_k_indices = sorted(range(len(scores)), key=lambda i: scores[i], reverse=True)[:top_k]\n", - " return [closest_texts[i] for i in top_k_indices]\n" + " return [closest_texts[i][0] for i in top_k_indices]\n" ] }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ @@ -662,24 +662,14 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 45, "metadata": {}, "outputs": [ { - "ename": "TypeError", - "evalue": "TextInputSequence must be str", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[51], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m scores \u001b[38;5;241m=\u001b[39m \u001b[43mreranker\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcompute_score\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtexts_to_rerank\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(scores)\n", - "File \u001b[0;32m~/Library/Caches/pypoetry/virtualenvs/rag-retrieval-rerank-_oC8k4Cq-py3.10/lib/python3.10/site-packages/torch/utils/_contextlib.py:115\u001b[0m, in \u001b[0;36mcontext_decorator..decorate_context\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 112\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 113\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdecorate_context\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 114\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m ctx_factory():\n\u001b[0;32m--> 115\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Library/Caches/pypoetry/virtualenvs/rag-retrieval-rerank-_oC8k4Cq-py3.10/lib/python3.10/site-packages/FlagEmbedding/flag_reranker.py:207\u001b[0m, in \u001b[0;36mFlagReranker.compute_score\u001b[0;34m(self, sentence_pairs, batch_size, max_length, normalize)\u001b[0m\n\u001b[1;32m 204\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m start_index \u001b[38;5;129;01min\u001b[39;00m tqdm(\u001b[38;5;28mrange\u001b[39m(\u001b[38;5;241m0\u001b[39m, \u001b[38;5;28mlen\u001b[39m(sentence_pairs), batch_size), desc\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCompute Scores\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 205\u001b[0m disable\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mlen\u001b[39m(sentence_pairs) \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m128\u001b[39m):\n\u001b[1;32m 206\u001b[0m sentences_batch \u001b[38;5;241m=\u001b[39m sentence_pairs[start_index:start_index \u001b[38;5;241m+\u001b[39m batch_size]\n\u001b[0;32m--> 207\u001b[0m inputs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtokenizer\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 208\u001b[0m \u001b[43m \u001b[49m\u001b[43msentences_batch\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 209\u001b[0m \u001b[43m \u001b[49m\u001b[43mpadding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 210\u001b[0m \u001b[43m \u001b[49m\u001b[43mtruncation\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 211\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_tensors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mpt\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 212\u001b[0m \u001b[43m \u001b[49m\u001b[43mmax_length\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmax_length\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 213\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mto(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdevice)\n\u001b[1;32m 215\u001b[0m scores \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmodel(\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39minputs, return_dict\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\u001b[38;5;241m.\u001b[39mlogits\u001b[38;5;241m.\u001b[39mview(\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m, )\u001b[38;5;241m.\u001b[39mfloat()\n\u001b[1;32m 216\u001b[0m all_scores\u001b[38;5;241m.\u001b[39mextend(scores\u001b[38;5;241m.\u001b[39mcpu()\u001b[38;5;241m.\u001b[39mnumpy()\u001b[38;5;241m.\u001b[39mtolist())\n", - "File \u001b[0;32m~/Library/Caches/pypoetry/virtualenvs/rag-retrieval-rerank-_oC8k4Cq-py3.10/lib/python3.10/site-packages/transformers/tokenization_utils_base.py:3055\u001b[0m, in \u001b[0;36mPreTrainedTokenizerBase.__call__\u001b[0;34m(self, text, text_pair, text_target, text_pair_target, add_special_tokens, padding, truncation, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, **kwargs)\u001b[0m\n\u001b[1;32m 3053\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_in_target_context_manager:\n\u001b[1;32m 3054\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_switch_to_input_mode()\n\u001b[0;32m-> 3055\u001b[0m encodings \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call_one\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtext\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtext\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtext_pair\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtext_pair\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mall_kwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3056\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m text_target \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 3057\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_switch_to_target_mode()\n", - "File \u001b[0;32m~/Library/Caches/pypoetry/virtualenvs/rag-retrieval-rerank-_oC8k4Cq-py3.10/lib/python3.10/site-packages/transformers/tokenization_utils_base.py:3142\u001b[0m, in \u001b[0;36mPreTrainedTokenizerBase._call_one\u001b[0;34m(self, text, text_pair, add_special_tokens, padding, truncation, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, split_special_tokens, **kwargs)\u001b[0m\n\u001b[1;32m 3137\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 3138\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mbatch length of `text`: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(text)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m does not match batch length of `text_pair`:\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3139\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlen\u001b[39m(text_pair)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3140\u001b[0m )\n\u001b[1;32m 3141\u001b[0m batch_text_or_text_pairs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mzip\u001b[39m(text, text_pair)) \u001b[38;5;28;01mif\u001b[39;00m text_pair \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m text\n\u001b[0;32m-> 3142\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mbatch_encode_plus\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 3143\u001b[0m \u001b[43m \u001b[49m\u001b[43mbatch_text_or_text_pairs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbatch_text_or_text_pairs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3144\u001b[0m \u001b[43m \u001b[49m\u001b[43madd_special_tokens\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43madd_special_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3145\u001b[0m \u001b[43m \u001b[49m\u001b[43mpadding\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpadding\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3146\u001b[0m \u001b[43m \u001b[49m\u001b[43mtruncation\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtruncation\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3147\u001b[0m \u001b[43m \u001b[49m\u001b[43mmax_length\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmax_length\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3148\u001b[0m \u001b[43m \u001b[49m\u001b[43mstride\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstride\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3149\u001b[0m \u001b[43m \u001b[49m\u001b[43mis_split_into_words\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mis_split_into_words\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3150\u001b[0m \u001b[43m \u001b[49m\u001b[43mpad_to_multiple_of\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpad_to_multiple_of\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3151\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_tensors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_tensors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3152\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_token_type_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_token_type_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3153\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_attention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_attention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3154\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_overflowing_tokens\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_overflowing_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3155\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_special_tokens_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_special_tokens_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3156\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_offsets_mapping\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_offsets_mapping\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3157\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_length\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_length\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3158\u001b[0m \u001b[43m \u001b[49m\u001b[43mverbose\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mverbose\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3159\u001b[0m \u001b[43m \u001b[49m\u001b[43msplit_special_tokens\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msplit_special_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3160\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3161\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3162\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 3163\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_plus(\n\u001b[1;32m 3164\u001b[0m text\u001b[38;5;241m=\u001b[39mtext,\n\u001b[1;32m 3165\u001b[0m text_pair\u001b[38;5;241m=\u001b[39mtext_pair,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 3182\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[1;32m 3183\u001b[0m )\n", - "File \u001b[0;32m~/Library/Caches/pypoetry/virtualenvs/rag-retrieval-rerank-_oC8k4Cq-py3.10/lib/python3.10/site-packages/transformers/tokenization_utils_base.py:3338\u001b[0m, in \u001b[0;36mPreTrainedTokenizerBase.batch_encode_plus\u001b[0;34m(self, batch_text_or_text_pairs, add_special_tokens, padding, truncation, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, split_special_tokens, **kwargs)\u001b[0m\n\u001b[1;32m 3328\u001b[0m \u001b[38;5;66;03m# Backward compatibility for 'truncation_strategy', 'pad_to_max_length'\u001b[39;00m\n\u001b[1;32m 3329\u001b[0m padding_strategy, truncation_strategy, max_length, kwargs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_padding_truncation_strategies(\n\u001b[1;32m 3330\u001b[0m padding\u001b[38;5;241m=\u001b[39mpadding,\n\u001b[1;32m 3331\u001b[0m truncation\u001b[38;5;241m=\u001b[39mtruncation,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 3335\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[1;32m 3336\u001b[0m )\n\u001b[0;32m-> 3338\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_batch_encode_plus\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 3339\u001b[0m \u001b[43m \u001b[49m\u001b[43mbatch_text_or_text_pairs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbatch_text_or_text_pairs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3340\u001b[0m \u001b[43m \u001b[49m\u001b[43madd_special_tokens\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43madd_special_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3341\u001b[0m \u001b[43m \u001b[49m\u001b[43mpadding_strategy\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpadding_strategy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3342\u001b[0m \u001b[43m \u001b[49m\u001b[43mtruncation_strategy\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtruncation_strategy\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3343\u001b[0m \u001b[43m \u001b[49m\u001b[43mmax_length\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmax_length\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3344\u001b[0m \u001b[43m \u001b[49m\u001b[43mstride\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstride\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3345\u001b[0m \u001b[43m \u001b[49m\u001b[43mis_split_into_words\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mis_split_into_words\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3346\u001b[0m \u001b[43m \u001b[49m\u001b[43mpad_to_multiple_of\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpad_to_multiple_of\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3347\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_tensors\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_tensors\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3348\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_token_type_ids\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_token_type_ids\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3349\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_attention_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_attention_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3350\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_overflowing_tokens\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_overflowing_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3351\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_special_tokens_mask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_special_tokens_mask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3352\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_offsets_mapping\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_offsets_mapping\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3353\u001b[0m \u001b[43m \u001b[49m\u001b[43mreturn_length\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mreturn_length\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3354\u001b[0m \u001b[43m \u001b[49m\u001b[43mverbose\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mverbose\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3355\u001b[0m \u001b[43m \u001b[49m\u001b[43msplit_special_tokens\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msplit_special_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3356\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3357\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/Library/Caches/pypoetry/virtualenvs/rag-retrieval-rerank-_oC8k4Cq-py3.10/lib/python3.10/site-packages/transformers/tokenization_utils_fast.py:528\u001b[0m, in \u001b[0;36mPreTrainedTokenizerFast._batch_encode_plus\u001b[0;34m(self, batch_text_or_text_pairs, add_special_tokens, padding_strategy, truncation_strategy, max_length, stride, is_split_into_words, pad_to_multiple_of, return_tensors, return_token_type_ids, return_attention_mask, return_overflowing_tokens, return_special_tokens_mask, return_offsets_mapping, return_length, verbose, split_special_tokens)\u001b[0m\n\u001b[1;32m 525\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_tokenizer\u001b[38;5;241m.\u001b[39mencode_special_tokens \u001b[38;5;241m!=\u001b[39m split_special_tokens:\n\u001b[1;32m 526\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_tokenizer\u001b[38;5;241m.\u001b[39mencode_special_tokens \u001b[38;5;241m=\u001b[39m split_special_tokens\n\u001b[0;32m--> 528\u001b[0m encodings \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_tokenizer\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mencode_batch\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 529\u001b[0m \u001b[43m \u001b[49m\u001b[43mbatch_text_or_text_pairs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 530\u001b[0m \u001b[43m \u001b[49m\u001b[43madd_special_tokens\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43madd_special_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 531\u001b[0m \u001b[43m \u001b[49m\u001b[43mis_pretokenized\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mis_split_into_words\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 532\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 534\u001b[0m \u001b[38;5;66;03m# Convert encoding to dict\u001b[39;00m\n\u001b[1;32m 535\u001b[0m \u001b[38;5;66;03m# `Tokens` has type: Tuple[\u001b[39;00m\n\u001b[1;32m 536\u001b[0m \u001b[38;5;66;03m# List[Dict[str, List[List[int]]]] or List[Dict[str, 2D-Tensor]],\u001b[39;00m\n\u001b[1;32m 537\u001b[0m \u001b[38;5;66;03m# List[EncodingFast]\u001b[39;00m\n\u001b[1;32m 538\u001b[0m \u001b[38;5;66;03m# ]\u001b[39;00m\n\u001b[1;32m 539\u001b[0m \u001b[38;5;66;03m# with nested dimensions corresponding to batch, overflows, sequence length\u001b[39;00m\n\u001b[1;32m 540\u001b[0m tokens_and_encodings \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 541\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_convert_encoding(\n\u001b[1;32m 542\u001b[0m encoding\u001b[38;5;241m=\u001b[39mencoding,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 551\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m encoding \u001b[38;5;129;01min\u001b[39;00m encodings\n\u001b[1;32m 552\u001b[0m ]\n", - "\u001b[0;31mTypeError\u001b[0m: TextInputSequence must be str" + "name": "stdout", + "output_type": "stream", + "text": [ + "[0.28374725580215454, -0.6582016348838806, -3.9359004497528076, -6.078181266784668, -5.264961242675781, 4.998556613922119, -5.124876022338867, -1.5439904928207397, -0.9592869877815247, -7.042023658752441, -5.507993221282959, -8.35011100769043, -7.134540557861328, -9.436647415161133, -7.423570156097412, 0.23653705418109894, -8.951774597167969, -5.671559810638428, -6.971182346343994, -7.249991416931152, -9.102521896362305, -2.066066265106201, -7.483180046081543, -7.791862964630127, -5.368914604187012]\n" ] } ], @@ -688,6 +678,69 @@ "print(scores)" ] }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Reranked Texts
0Chapter 1 | Introduction to Embedded Systems \\n33Proposed Exercise\\n1. How can the code be changed in such a way that the system is blocked after three incorrect codes \\nare entered?\\nAnswer to the Exercise\\n1. It can be achieved by means of the change in T able 1.11.\\nT able 1.11 Proposed modification in the code in order to achieve the new behavior.\\nLine in Code 1.5 New code to be used\\n40 if ( numberOfIncorrectCodes < 5 ) 40 if ( numberOfIncorrectCodes < 3 )\\n1.3 Under the Hood\\n1.3.1 Brief Introduction to the Cortex-M Processor Family and the NUCLEO Board\\nIn this chapter, many programs were developed using the NUCLEO board, provided with the \\nSTM32F429ZIT6U microcontroller . This microcontroller is manufactured by STMicroelectronics [13]
1Index\\n567 STM 32F429 ZIT 6U microcontroller 5, 33, 37, 38 \\n stop bit 46, 64, 65, 80, 256 , 257 , 273 , 468 \\n ST Zio connectors xiv, 6, 9, 37, 38, 44, 346 \\n superloop 13, 519 \\n synchronous communication 255\\nT TCP server 456 , 457 , 459 , 460 –463 , 491 \\n temperature sensor 4, 5, 87, 106 , 123 , 182 , 220 , 233 , 334 , 486 , 550 \\n time management xvi, 86, 95, 99, 289 , 342 , 348 , 353 \\n timers xvi, xxvii, 37, 306 , 342 , 343 , 345 , 348 –350 , 353 , 354 , \\n 361 , 441 , 512 –517 , 533 , 535 , 537 , 538 , 539 \\n tm structure 153 \\n TO- 220 package 89\\nU UART xvi, xvii, 5, 44, 61, 63, 79, 82, 84, 86, 181 , 191 , 222 , 255 , 290 , 291 , \\n 306 , 350 , 420 , 423 , 447 , 455 , 461 , 465 , 468 , 544 \\n USB xiv, xxvii, 4, 9, 37, 44, 45, 63, 79, 82, 88, 132 , 449 , 506 , 507 , 508 , 544 \\n USB connection xiv, 44, 506 \\n use cases 497 , 501 –504 , 511 , 545 , 546 , 547 , 548\\nV validation 496 , 497 , 546 , 547 \\n verification 81, 92, 496 , 497 , 546 \\n vineyard frost prevention 123 , 124
2346\\nA Beginner’s Guide to Designing Embedded System ApplicationsNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK\\nSPI4_SCK\\nSPI5_SCKSPI4_CSSPI3_MISO\\nSPI3_MOSI\\nSPI3_MOSI\\nSPI2_MOSI\\nPWM1/1NPWM2/4\\nPWM11/1PWM3/3\\nI2C3_SDA PWM3/4\\nA0\\nA1\\nA2\\nA3\\nA4\\nA5\\nADC3/6 PF_8 SPI5_MISO PWM /131\\nADC3/7 PF_9 SPI5_MOSI PWM /141PE_6 SPI4_MOSI PWM /29PE_5 SPI4_MISO PWM /91\\nUART _TX6\\nUART_X6R\\nUART_X1T\\nUART _RTS3\\nUART _CTS3\\nUART_X4T
\n", + "
" + ], + "text/plain": [ + " Reranked Texts\n", + "0 Chapter 1 | Introduction to Embedded Systems \\n33Proposed Exercise\\n1. How can the code be changed in such a way that the system is blocked after three incorrect codes \\nare entered?\\nAnswer to the Exercise\\n1. It can be achieved by means of the change in T able 1.11.\\nT able 1.11 Proposed modification in the code in order to achieve the new behavior.\\nLine in Code 1.5 New code to be used\\n40 if ( numberOfIncorrectCodes < 5 ) 40 if ( numberOfIncorrectCodes < 3 )\\n1.3 Under the Hood\\n1.3.1 Brief Introduction to the Cortex-M Processor Family and the NUCLEO Board\\nIn this chapter, many programs were developed using the NUCLEO board, provided with the \\nSTM32F429ZIT6U microcontroller . This microcontroller is manufactured by STMicroelectronics [13]\n", + "1 Index\\n567 STM 32F429 ZIT 6U microcontroller 5, 33, 37, 38 \\n stop bit 46, 64, 65, 80, 256 , 257 , 273 , 468 \\n ST Zio connectors xiv, 6, 9, 37, 38, 44, 346 \\n superloop 13, 519 \\n synchronous communication 255\\nT TCP server 456 , 457 , 459 , 460 –463 , 491 \\n temperature sensor 4, 5, 87, 106 , 123 , 182 , 220 , 233 , 334 , 486 , 550 \\n time management xvi, 86, 95, 99, 289 , 342 , 348 , 353 \\n timers xvi, xxvii, 37, 306 , 342 , 343 , 345 , 348 –350 , 353 , 354 , \\n 361 , 441 , 512 –517 , 533 , 535 , 537 , 538 , 539 \\n tm structure 153 \\n TO- 220 package 89\\nU UART xvi, xvii, 5, 44, 61, 63, 79, 82, 84, 86, 181 , 191 , 222 , 255 , 290 , 291 , \\n 306 , 350 , 420 , 423 , 447 , 455 , 461 , 465 , 468 , 544 \\n USB xiv, xxvii, 4, 9, 37, 44, 45, 63, 79, 82, 88, 132 , 449 , 506 , 507 , 508 , 544 \\n USB connection xiv, 44, 506 \\n use cases 497 , 501 –504 , 511 , 545 , 546 , 547 , 548\\nV validation 496 , 497 , 546 , 547 \\n verification 81, 92, 496 , 497 , 546 \\n vineyard frost prevention 123 , 124\n", + "2 346\\nA Beginner’s Guide to Designing Embedded System ApplicationsNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK\\nSPI4_SCK\\nSPI5_SCKSPI4_CSSPI3_MISO\\nSPI3_MOSI\\nSPI3_MOSI\\nSPI2_MOSI\\nPWM1/1NPWM2/4\\nPWM11/1PWM3/3\\nI2C3_SDA PWM3/4\\nA0\\nA1\\nA2\\nA3\\nA4\\nA5\\nADC3/6 PF_8 SPI5_MISO PWM /131\\nADC3/7 PF_9 SPI5_MOSI PWM /141PE_6 SPI4_MOSI PWM /29PE_5 SPI4_MISO PWM /91\\nUART _TX6\\nUART_X6R\\nUART_X1T\\nUART _RTS3\\nUART _CTS3\\nUART_X4T" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "top_3_texts_from_rerank_scores = get_top_k_texts_from_rerank_scores(scores, twenty_five_closest_texts, top_k=3)\n", + "pd.DataFrame(top_3_texts_from_rerank_scores, columns=[\"Reranked Texts\"])" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -696,20 +749,11 @@ "\n", "The goal here is to verify if following context is present in any of the retrieved documents.\n", "\n", - "> In this chapter, many programs were developed using the NUCLEO board, provided with the STM32F429ZIT6U microcontroller. This microcontroller is manufactured by STMicroelectronics [13] using a Cortex-M4 processor designed by Arm Ltd. [14].\n", + "> This microcontroller is manufactured by STMicroelectronics\n", "\n", - "If it is present then our retrieval approach was able to find the correct document from the vector store.\n", + "If it is present then our reranking approach was able to find the correct document from the vector store.\n", "\n", - "> It is present in the second row of Retrieved text in the first result as shown below." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "get_top_3_texts_from_rerank_scores(scores, twenty_five_closest_texts, top_k=3)" + "> It is present in the first row of Reranked text in the first result as shown below." ] }, { @@ -723,20 +767,228 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 55, "metadata": {}, - "outputs": [], - "source": [ - "scores_for_all_25_documents = pd.DataFrame({\"Received Texts\": twenty_five_closest_texts, \"Score\": scores})" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
Received TextsScore
5(Chapter 1 | Introduction to Embedded Systems \\n33Proposed Exercise\\n1. How can the code be changed in such a way that the system is blocked after three incorrect codes \\nare entered?\\nAnswer to the Exercise\\n1. It can be achieved by means of the change in T able 1.11.\\nT able 1.11 Proposed modification in the code in order to achieve the new behavior.\\nLine in Code 1.5 New code to be used\\n40 if ( numberOfIncorrectCodes < 5 ) 40 if ( numberOfIncorrectCodes < 3 )\\n1.3 Under the Hood\\n1.3.1 Brief Introduction to the Cortex-M Processor Family and the NUCLEO Board\\nIn this chapter, many programs were developed using the NUCLEO board, provided with the \\nSTM32F429ZIT6U microcontroller . This microcontroller is manufactured by STMicroelectronics [13], 0.787173867)4.998557
0(Index\\n567 STM 32F429 ZIT 6U microcontroller 5, 33, 37, 38 \\n stop bit 46, 64, 65, 80, 256 , 257 , 273 , 468 \\n ST Zio connectors xiv, 6, 9, 37, 38, 44, 346 \\n superloop 13, 519 \\n synchronous communication 255\\nT TCP server 456 , 457 , 459 , 460 –463 , 491 \\n temperature sensor 4, 5, 87, 106 , 123 , 182 , 220 , 233 , 334 , 486 , 550 \\n time management xvi, 86, 95, 99, 289 , 342 , 348 , 353 \\n timers xvi, xxvii, 37, 306 , 342 , 343 , 345 , 348 –350 , 353 , 354 , \\n 361 , 441 , 512 –517 , 533 , 535 , 537 , 538 , 539 \\n tm structure 153 \\n TO- 220 package 89\\nU UART xvi, xvii, 5, 44, 61, 63, 79, 82, 84, 86, 181 , 191 , 222 , 255 , 290 , 291 , \\n 306 , 350 , 420 , 423 , 447 , 455 , 461 , 465 , 468 , 544 \\n USB xiv, xxvii, 4, 9, 37, 44, 45, 63, 79, 82, 88, 132 , 449 , 506 , 507 , 508 , 544 \\n USB connection xiv, 44, 506 \\n use cases 497 , 501 –504 , 511 , 545 , 546 , 547 , 548\\nV validation 496 , 497 , 546 , 547 \\n verification 81, 92, 496 , 497 , 546 \\n vineyard frost prevention 123 , 124, 0.824654)0.283747
15(346\\nA Beginner’s Guide to Designing Embedded System ApplicationsNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK\\nSPI4_SCK\\nSPI5_SCKSPI4_CSSPI3_MISO\\nSPI3_MOSI\\nSPI3_MOSI\\nSPI2_MOSI\\nPWM1/1NPWM2/4\\nPWM11/1PWM3/3\\nI2C3_SDA PWM3/4\\nA0\\nA1\\nA2\\nA3\\nA4\\nA5\\nADC3/6 PF_8 SPI5_MISO PWM /131\\nADC3/7 PF_9 SPI5_MOSI PWM /141PE_6 SPI4_MOSI PWM /29PE_5 SPI4_MISO PWM /91\\nUART _TX6\\nUART_X6R\\nUART_X1T\\nUART _RTS3\\nUART _CTS3\\nUART_X4T, 0.773790121)0.236537
1(Chapter 1 | Introduction to Embedded Systems \\n37The STM32F429ZIT6U microcontroller includes a Cortex-M4 processor , as shown in Figure 1.22. It \\ncan be appreciated that, beyond the processor, the microcontroller includes other peripherals such as \\ncommunication cores (ethernet, USB, UART, etc.), memory, timers, and GPIO (General Purpose Input Output) ports. \\nNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK, 0.808520198)-0.658202
8([2] “HD44780U (LCD-II) (Dot Matrix Liquid Crystal Display Controller/Driver)” . Accessed July 9, 2021. https://www.sparkfun.com/datasheets/LCD/HD44780.pdf \\n[3] “GitHub - armBookCodeExamples/Directory” . Accessed July 9, 2021. https://github.com/armBookCodeExamples/Directory/ \\n[4] “NUCLEO-F429ZI | Mbed” . Accessed July 9, 2021. https://os.mbed.com/platforms/ST-Nucleo-F429ZI/ \\n[5] “ASCII | Wikipedia” . Accessed July 9, 2021. https://en.wikipedia.org/wiki/ASCII \\n[6] “I2C Serial Interface Adapter Module for LCD” . Accessed July 9, 2021. https://components101.com/modules/i2c-serial-interface-adapter-module \\n[7] “PCF8574 Remote 8-Bit I/O Expander for I2C Bus” . Accessed July 9, 2021. https://www.ti.com/lit/ds/symlink/pcf8574.pdf \\n[8] “Addressing - I2C Bus” . Accessed July 9, 2021. https://www.i2c-bus.org/addressing/ \\n[9] “ST7290 GLCD Pinout, Features, Interfacing & Datasheet” . Accessed July 9, 2021. https://components101.com/displays/st7290-graphical-lcd, 0.781838417)-0.959287
7(List of Figures\\nxxxiv\\nFigure 1.19 Simplified diagram of the Cortex processor family. 33\\nFigure 1.20 Simplified diagram of the Cortex M0, M3, and M4 processors, and details of the \\ncorresponding cores. 34\\nFigure 1.21 Arm Cortex M0, M3, and M4 Instruction Set Architecture (ISA). 35\\nFigure 1.22 STM32F429ZI block diagram made using information available from [9]. 36\\nFigure 1.23 ST Zio connectors of the NUCLEO-F429ZI board. 37\\nFigure 1.24 Hierarchy of different elements introduced in this chapter. 38\\nFigure 1.25 “Smart door locks” built with Mbed contains elements introduced in this chapter. 39\\nFigure 2.1 The smart home system is now connected to a PC. 45\\nFigure 2.2 Website with the program documentation generated with Doxygen. 57\\nFigure 2.3 Detailed description of functions and variables of the program that is available on the website (Part 1/3). 57\\nFigure 2.4 Detailed description of functions and variables of the program that is available on the website (Part 2/3). 58, 0.782111764)-1.543990
21(SPI1_MISOSPI2_CS\\nSPI1_MOSICAN1_RD I2C1_SCL\\nI2C1_SDA CAN1_TD\\nPWM3/1PWM2/1\\nPWM1/1N\\nPWM4/3PWM4/3\\nPWM4/4PWM4/4PB_8\\nPB_9\\nPA_5\\nPA_6\\nPA_7\\nPD_14\\nPD_15\\nPF_12GND\\nADC1/5\\nADC1/6\\nADC1/7DAC1/2\\nFigure 8.5 ST Zio connectors of the NUCLEO-F429ZI board., 0.765687525)-2.066066
2(USAR Tn\\nbxCANnsmcard\\nirDA\\nFIFODigital\\nfilter\\nDACnAPB1 45 MHz (max)AHB1 180 MHzAHB3\\nVDD = 1.8 to 3.6V\\nVSS\\nVCAP1, VCAP2APB2 90 MHzART\\nACCEL/CACHE\\nGPIO POR TtOSC32_I N\\nOSC32_OUTDMA2USB\\nOTG HS\\n8 Streams\\nFIFODMA/\\nFIFO PHY\\nCHROM-AR T\\nDMA2DFIFO\\nFIFO8 Streams\\nFIFODMA1\\nLCD_R[7:0], LCD_G[7:0] ,\\nLCD_B[7:0], LCD_HSYNC,\\nLCD_VSYNC, LCD_DE,\\nLCD_CLKLCD-TFTDMA/\\nFIFO\\nRTC_AF1\\nRTC_AF1\\nRTC 50Hz\\n4KB BXPSRAMLS@ VBAT\\nRTC\\nAWU\\nBackup registerXTAL32 KHz\\nLSStandby\\ninterfaceIWDGXTALOSC 4-26 MHzPOR\\nreset\\nInt\\n@ VDDA @ VDDPVDPOR/PDR BORSupply\\nsupervision@ VDDVDD\\nVoltage regulator\\n3.3 to 1.2VPower\\nmanagement\\nPLL1, 2, 3RC LSRC HS@ VDDA\\nReset\\n& clock\\ncontrol\\nFigure 1.22 STM32F429ZI block diagram made using information available from [9]., 0.807650089)-3.935900
6(38\\nA Beginner’s Guide to Designing Embedded System ApplicationsFigure 1.23 shows how different elements of the STM32F429ZIT6U microcontroller are mapped \\nto the Zio and Arduino-compatible headers of the NUCLEO-F429ZI board. Some other elements \\nare mapped to the CN11 and CN12 headers of the NUCLEO-F429ZI board, as will be discussed in upcoming chapters. Further information on these headers is available from [17].\\nIn this chapter, buttons were connected to the NUCLEO board using pins D2 to D7. From Figure 1.23, \\nit can be seen that those digital inputs can also be referred to as PF_15, PE_13, P_14, PE_11, PE_9, and PF_13, respectively. Throughout this book, many pins of the ST Zio connectors will be used, and they will be referred to in the code using the names shown in Figure 1.23., 0.782175064)-5.124876
4(// commented// See https://os.mbed.com/teams/ST/wiki/STDIO for more information.////==============================================================================\\nCode 8.1 Notes on the PinNames.h file of the NUCLEO-F429ZI board.\\nCode 8.2 and Code 8.3 show the section of PinNames.h regarding PWM pins. For example, on line 4 \\nof Code 8.2, it can be seen that PA_0 is related to PWM2 and channel 1 (channel 1 is indicated by \\nthe 1 that is the penultimate value of line 4), which is used to control the green LED of the RGB LED \\n(see Figure 8.3). This “normal” functionality of PA_0 is shown in Figure 8.5. In line 1 of Code 8.3, it can be seen that PB_0 is related to PWM1 and channel 2, with inverted behavior (ultimate value 1 of line 1). Inverted behavior means that a logic true is set by a 0 V value, as was explained above. This functionality is also shown on Figure 8.5.\\n1\\n23456789\\n10111213141516171819202122//*** PWM ***, 0.788461)-5.264961
24(MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_PWM[] = { {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 2, 0)}, {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 3, 0)}, {PA_2_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM9, 1, 0)}, {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 4, 0)}, {PA_3_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM9, 2, 0)}, {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, {PA_5_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 1, 1)}, {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 1, 0)}, {PA_6_ALT0, PWM_13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_TIM13, 1, 0)}, {PA_7,, 0.765086949)-5.368915
10({PA_7_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 1, 1)}, {PA_7_ALT2, PWM_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_TIM14, 1, 0)}, {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 1, 0)}, {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 2, 0)}, {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 3, 0)}, {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 4, 0)}, {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_P\\nP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, \\nCode 8.2 Notes on the PinNames.h file of the NUCLEO-F429ZI board.\\nIt can be seen that PWM functionality is available as alternative functionality in more pins indicated as, 0.779603779)-5.507993
17(101112131415161718192021222324252627282930313233343536373839404142424344454647484950 {PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 4, 1)}, {PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 3, 0)}, {PB_0_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 2, 1)}, {PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 3, 1)}, {PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 4, 0)}, {PB_1_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 3, 1)}, {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 2, 0)}, {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 1, 0)}, {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 2, 0)}, {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP,, 0.772038043)-5.671560
3(337 , 388 , 455 , 506 , 508 \\n preprocessor directive 217 \\n processor xvi, xxii, xxvi, 33–35, 37, 38, 41, 44, 124 , 353 , 420 , 439 \\n project management 501 \\n Proyecto CIAA xiii, xxiii, xxiv, 443 \\n pull-down resistor 14, 23, 55, 111 \\n pull-up resistor 14, 15, 92, 253 , 255 , 521 , 522 \\n Pulse-Code Modulation (PCM) 354 \\n pulse-width modulation xxvii, 342 , 343 , 345 , 347 –351 , 353 –357 , 360 –362 , \\n 364 –367 , 379 , 380 , 383 –385 , 552\\nR Real Time Clock (RTC) 126 , 132 , 133 , 149 , 153 , 155 , 160 , 167 , 181 , 182 , 193 , 393 , 396 \\n reference operator 151 , 153 , 156 , 261 , 311 , 439 \\n relay module 296 , 299 , 301 , 336 –339 , 506 , 508 , 510 , 514 –516 , 530 \\n repository xxv, xxvi, xxvii, 10, 387 , 388 , 393 , 413 –415 , 416 , 417 , 503 , 546 \\n requirements 2, 497 , 498 , 501 –506 , 510 , 511 , 521 , 522 , 533 , 545 –548 \\n responsiveness 97 \\n RGB LED 342 –345 , 348 –350 , 356 , 357 , 360 –364 , 370 , 373 , 374 , 383 –385 \\n rising edge interrupts 320 , 323 , 324, 0.791497)-6.078181
18(Chapter 12 | Guide to Designing and Implementing an Embedded System Project\\n553 References\\n[1] “NUCLEO-F429ZI | Mbed” . Accessed July 9, 2021. \\nhttps://os.mbed.com/platforms/ST-Nucleo-F429ZI/#zio-and-arduino-compatible-headers \\n[2] “GitHub - armBookCodeExamples/Directory” . Accessed July 9, 2021. https://github.com/armBookCodeExamples/Directory \\n[3] Pham, H. (1999). Software Reliability. John Wiley & Sons, Inc. p. 567. ISBN 9813083840., 0.768167377)-6.971182
9(Preface\\nxx10A250V AC 10A 125V ACCU S\\n10A 0VDC 10A VDC 32 8\\nSRD-05VDC-SL- CCQCRSONGLE\\n10A250V AC 10A 125V ACCU S\\n10A 0VDC 10A VDC 32 8\\nSRD-05VDC-SL- CCQCRSONGLE\\n2 Relay ModuleK2 K1\\nJD-VCC VCC GND GND IN1 IN2 VCCR3 R2D2 D2Q2 Q1\\nIN2 IN1\\nR4 R1+ +\\nB1810\\n817C\\nGB1810\\n817C\\nG\\n1982A 12381H2FPD-270A\\nSolenoid valve External 12V\\nPower source\\nGND12\\n12V\\nAC POWER Adapte r\\nInput 240 VCA\\nOutpur 12V CC 2A\\nErPAri\\nHL-69\\nMoisture\\nsensor\\nEPARIDO-LED\\nAO DO GND VCC\\nPWR-LED\\n+\\n+\\n--\\n--\\n+\\n+\\n--\\n--123456789101112131415161718192021222324252627282930f g\\nh i\\njf g\\nh i\\nja b\\nc d\\nea b\\nc d\\ne123456789101112131415161718192021222324252627282930(Relay IN1)\\ndPF2_5V GND\\n5V\\nGNDNUCLEO-F429Z\\nI\\n32F429ZIT6UAR\\nM\\n7B776 VQPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n12000K620 Y DGKYDKMS-1102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n3.3V\\nGNDD4 to D7D8,D9CN9 CN8\\nCN7CN10Relay module\\nCN9\\nPF 9_\\nPF 7_\\nPF 8_\\nPG 1_(Mode)(How Often)(How Long)(Moisture)COM11NO\\nA3\\nVDDVSS VORSRWED0D1D2D3D4D5D6D7A K11 6, 0.7817837)-7.042024
12(outputs, some fixed and some selectable. \\nWaRning: The selectable outputs should be configured as indicated in Figure 4.7. Otherwise, some modules may be harmed. \\nGND 3V3GND V53V3 5V\\n3V3 5VVoltage\\nselectorsOutput\\nPowerFixed\\n5V\\nFixed\\n3.3VInput\\nPower\\noptions5V\\nMini\\nUSB-B\\n7 to 12 V\\nJackSelectable\\n5V or 3.3VSelectable\\n5V or 3.3V\\nFigure 4.7 Diagram of the MB102 module.\\n4.2.2 T est the Operation of the Matrix Keypad and the RTC\\nThis subsection explains how to load a program onto the STM32 microcontroller in order to test if the matrix keypad that has been connected is working properly. It will also show how to configure the RTC of the STM32 microcontroller. The serial terminal will display the keys that are pressed on the matrix keypad, and the PC keyboard will be used to configure the date and time of the RTC. The .bin file of the \\nprogram “Subsection 4.2.2” should be downloaded from the URL available in [4] and dragged onto the NUCLEO board., 0.774262786)-7.134541
19(M_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_TIM14, 1, 0)}, \\n {NC, NC, 0}\\n}; \\nCode 8.3 Notes on the PinNames.h file of the NUCLEO-F429ZI board., 0.766855717)-7.249991
14([10] “ST7920 Chinese Fonts built in LCD controller/driver” . Accessed July 9, 2021. https://pdf1.alldatasheet.es/datasheet-pdf/view/326219/SITRONIX/ST7920.html, 0.773805916)-7.423570
22(422\\nA Beginner’s Guide to Designing Embedded System Applications(Relay GND)(Relay VCC)\\nNUCLEO-F429Z\\nI\\n32F429ZIT6UARM\\n7B776 VQPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n12000K620 Y DGKYDKMS-1102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717CN8\\n+\\n+\\n--\\n--\\n+\\n+\\n--\\n--123456789101112131415161718192021222324252627282930f g\\nh i\\njf g\\nh i\\nja b\\nc d\\nea b\\nc d\\ne123456789101112131415161718192021222324252627282930\\nMQ-2\\nGas sensor\\n-2MQ\\nGND5V\\nRGB LEDGND 3V3GND V53V3 5V\\n3V3 5VMB-102CN9\\nCN7CN10GND\\n3.3VPotentiometer\\n5V\\nGNDA1Temperature\\nsensorLM35\\n3.3V\\n5V\\nGNDGNDHV1HV2HV\\nLVHV3\\nLV3LV3 LV1HV4\\nLV4LV4 LV2GND\\nGND\\nGNDVCCVORSR/WEDBDBDBDBDBDBDBDB01234567\\nNCPSB RSTVOUTBLABLK\\n1 20A0PG 0_10KΩ GND 5V25V2uF 220\\n25V2uF 220\\n25V2uF 220PIR\\nsensor\\nRed\\nGND\\nBlue\\nGreenPE 12_(Gas)\\nPF 9_\\nPF 7_\\nPF 8_\\nPG 1_(Dir1LS)\\n(Dir1)\\nPE 6_(Audio)\\n(DirLS)2\\n(Dir)2\\nPB 4_\\nPD 12_\\nPA0_(Red)(Blue)(Green)\\nLDRL 35M\\nPC 9_Buzzer\\n5V\\nDO1033.3V\\nSD card and\\nSD card readerGND\\nA\\nB\\nC\\nD871\\n42\\n53\\n6\\n9\\n0 #\\n5151\\n10K\\nJAPANFCCvRKingston\\n1\\nSDCS/32GB, 0.765655637)-7.483180
23(GPIO_AF9_TIM13, 1, 0)}, {PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 1, 1)}, {PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 2, 0)},, 0.765156627)-7.791863
11(1\\n23456789\\n101112typedef struct{ int address; char data; bool displayPinRs; bool displayPinRw; bool displayPinEn; bool displayPinA; bool displayPinD4; bool displayPinD5; bool displayPinD6; bool displayPinD7;} pcf8574_t;\\nCode 6.23 New private data type used to implement the control of the LCD pins using the PCF8574 LCD module. \\nA private variable of type pcf8574_t is declared in display.cpp, as shown in Code 6.24.\\n1static pcf8574_t pcf8574;\\nCode 6.24 Declaration of a private variable of type pcf8574_t. \\nThe implementation of displayInit() is shown in Code 6.25 and Code 6.26. In line 3 of Code 6.25, \\ndisplay.connection is assigned and in line 5 it is evaluated to establish if it is equal to \\nDISPLAY_CONNECTION_I2C_PCF8574_IO_EXPANDER. If so, pcf8574.address and pcf8574.data are, 0.779199779)-8.350111
16(152\\nA Beginner’s Guide to Designing Embedded System Applications1\\n23456789\\n10111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364case 's':case 'S': struct tm rtcTime; int strIndex; uartUsb.write( \"\\r\\nType four digits for the current year (YYYY): \" , 48 );\\n for( strIndex=0; strIndex<4; strIndex++ ) { uartUsb.read( &str[strIndex] , 1 ); uartUsb.write( &str[strIndex] ,1 ); } str[4] = '\\0'; rtcTime.tm_year = atoi(str) - 1900; uartUsb.write( \"\\r\\n\", 2 );\\n uartUsb.write( \"Type two digits for the current month (01-12): \", 47 );\\n for( strIndex=0; strIndex<2; strIndex++ ) { uartUsb.read( &str[strIndex] , 1 ); uartUsb.write( &str[strIndex] ,1 ); } str[2] = '\\0'; rtcTime.tm_mon = atoi(str) - 1; uartUsb.write( \"\\r\\n\", 2 );\\n uartUsb.write( \"Type two digits for the current day (01-31): \", 45 );, 0.773067594)-8.951775
20(2 (The same elements are used as in Chapter 1.) –\\n3LM35 temperature sensor 1\\n10 kΩ potentiometer 2\\nMQ-2 gas sensor 1\\n5V buzzer 1\\nResistors: 100 Ω, 150 Ω, 330 Ω, 1 kΩ, 10 kΩ, 47 kΩ, 100 kΩ \\n(100 kΩ are used in this chapter and the other resistors in different chapters. See note below.) 10 of each value\\nJumper wires (male–female) 80\\n4Matrix keypad (4 × 4) 1\\n90-degrees 2.54 mm (.1”) pitch pin header 40\\nMB102 breadboard power supply \\n(One is used in this chapter and the other in Chapter 7.) 2\\nUSB–mini-USB cable 2\\n5BC548C NPN transistor (One is used in this chapter and the other in Chapter 8.) 2\\n6Character-based LCD display 20 × 4, based on HD44780 1\\nI2C PCF8574 expander 1\\n10 kΩ trimpot 1\\nBidirectional logic level converter 1\\nJumper wires (female–female) 40\\nGraphic LCD display, based on ST7920 1, 0.766771555)-9.102522
13(TIM / PWMn\\nTIMnTIM9\\nUSAR TnPort P [15:0] t\\nwith t =A to KArm Cortex-M4\\n180 Mhz\\nFPUCCM data RAM 64 KB\\nD-BUSNVICMPU\\nD-BUS\\nD-BUSArm Cortex-M4\\nProcessorETMJTAG & SW\\nEthernet MAC\\n10/100MII or RMII as AF\\nMDIO as AFExternal memory controller (FMC)\\nSRAM, SDRAM, PSRAM,\\nNOR Flash, PC Card, NAND Flash\\nUSB\\nOTG FSCamera\\ninterface2x\\n1MB Flash\\nSRAM\\n112, 16 & 64 KBRING\\nFIFOFIFO\\nPHY\\n16b\\n16b\\n16b\\nsmcard\\nirDA\\nSD, SCK, FS, MCLK as AFSPIn\\nADC1Temperature sensor\\nADC2I F\\nADC3SAI1APB2 90 MHzFIFO\\nTIMnWWDG\\n16b1 channela sAF\\nwith n = 13 or 144 channels, ETR as AF\\nwith n = 3 or 44 channels, ETR as AF\\n2 channels asAF4 channels\\nMOSI/SD, MISO/SD_ext,\\nSCK/CK, NSS/WS, MC K\\nasAFwith n = 2 or 3RX,T X as AF\\nwith n = 4, 5, 7 or 8\\nSCL, SDA, SMBA asAF\\nwith n = 1, 2 or 3RX,TX, CK, CST, RTS\\nasAFwith n = 2 or 3\\nTX, RXwith n = 1 or 2\\nDAC _OUT asAF n\\nwith n = 1 or 2 ITFTIMnTIMn\\nTIM12TIM5TIM2\\nAHB/APB2DMA2 DMA1\\nAHB/APB1\\nSP/ 2SInnUAR Tn\\nI2C /SMBUSn16b16b\\n16b32b32b\\nUSAR Tn\\nbxCANnsmcard\\nirDA\\nFIFODigital\\nfilter, 0.77420038)-9.436647
\n", + "
" + ], + "text/plain": [ + " Received Texts \\\n", + "5 (Chapter 1 | Introduction to Embedded Systems \\n33Proposed Exercise\\n1. How can the code be changed in such a way that the system is blocked after three incorrect codes \\nare entered?\\nAnswer to the Exercise\\n1. It can be achieved by means of the change in T able 1.11.\\nT able 1.11 Proposed modification in the code in order to achieve the new behavior.\\nLine in Code 1.5 New code to be used\\n40 if ( numberOfIncorrectCodes < 5 ) 40 if ( numberOfIncorrectCodes < 3 )\\n1.3 Under the Hood\\n1.3.1 Brief Introduction to the Cortex-M Processor Family and the NUCLEO Board\\nIn this chapter, many programs were developed using the NUCLEO board, provided with the \\nSTM32F429ZIT6U microcontroller . This microcontroller is manufactured by STMicroelectronics [13], 0.787173867) \n", + "0 (Index\\n567 STM 32F429 ZIT 6U microcontroller 5, 33, 37, 38 \\n stop bit 46, 64, 65, 80, 256 , 257 , 273 , 468 \\n ST Zio connectors xiv, 6, 9, 37, 38, 44, 346 \\n superloop 13, 519 \\n synchronous communication 255\\nT TCP server 456 , 457 , 459 , 460 –463 , 491 \\n temperature sensor 4, 5, 87, 106 , 123 , 182 , 220 , 233 , 334 , 486 , 550 \\n time management xvi, 86, 95, 99, 289 , 342 , 348 , 353 \\n timers xvi, xxvii, 37, 306 , 342 , 343 , 345 , 348 –350 , 353 , 354 , \\n 361 , 441 , 512 –517 , 533 , 535 , 537 , 538 , 539 \\n tm structure 153 \\n TO- 220 package 89\\nU UART xvi, xvii, 5, 44, 61, 63, 79, 82, 84, 86, 181 , 191 , 222 , 255 , 290 , 291 , \\n 306 , 350 , 420 , 423 , 447 , 455 , 461 , 465 , 468 , 544 \\n USB xiv, xxvii, 4, 9, 37, 44, 45, 63, 79, 82, 88, 132 , 449 , 506 , 507 , 508 , 544 \\n USB connection xiv, 44, 506 \\n use cases 497 , 501 –504 , 511 , 545 , 546 , 547 , 548\\nV validation 496 , 497 , 546 , 547 \\n verification 81, 92, 496 , 497 , 546 \\n vineyard frost prevention 123 , 124, 0.824654) \n", + "15 (346\\nA Beginner’s Guide to Designing Embedded System ApplicationsNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK\\nSPI4_SCK\\nSPI5_SCKSPI4_CSSPI3_MISO\\nSPI3_MOSI\\nSPI3_MOSI\\nSPI2_MOSI\\nPWM1/1NPWM2/4\\nPWM11/1PWM3/3\\nI2C3_SDA PWM3/4\\nA0\\nA1\\nA2\\nA3\\nA4\\nA5\\nADC3/6 PF_8 SPI5_MISO PWM /131\\nADC3/7 PF_9 SPI5_MOSI PWM /141PE_6 SPI4_MOSI PWM /29PE_5 SPI4_MISO PWM /91\\nUART _TX6\\nUART_X6R\\nUART_X1T\\nUART _RTS3\\nUART _CTS3\\nUART_X4T, 0.773790121) \n", + "1 (Chapter 1 | Introduction to Embedded Systems \\n37The STM32F429ZIT6U microcontroller includes a Cortex-M4 processor , as shown in Figure 1.22. It \\ncan be appreciated that, beyond the processor, the microcontroller includes other peripherals such as \\ncommunication cores (ethernet, USB, UART, etc.), memory, timers, and GPIO (General Purpose Input Output) ports. \\nNUCLEO\\n-F429ZI32F429ZIT6U\\nARM7B776 VQ\\nPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n120 00K620 YDGKYD\\nKMS-1 102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n11\\n22\\n33\\n44\\n55\\n66\\n77\\n88\\n9\\n10\\n11\\n12\\n13\\n14\\n15PH_0\\nPD_0\\nPD_1\\nPG_0PH_1PF_2PA_7PF_10PF_5PF_3PC_3PC_030\\n29\\n28\\n27\\n2616\\n2515\\n2414\\n2313\\n2212\\n2111\\n2010\\n199\\n18\\n17\\n165V\\nVIN3.3VIOREF\\nGND\\nGNDGND\\nNCNC\\nUART2_RX\\nCAN1_TDCAN1_ DRADC1/7ADC1/3\\nADC1/10\\nADC1/13\\nADC3/9\\nADC3/15\\nADC3/8\\nADC3/5NRSTPC_8\\nPC_9\\nPC_10\\nPC_11\\nPC_12\\nPD_2\\nPG_2\\nPG_3\\nGNDPD_7\\nPD_6\\nPD_5\\nPD_4\\nPD_3\\nPE_2\\nPE_4\\nPE_3\\nPF_7\\nPG_1UART2_RX\\nUART2_ XT\\nUART_X7TUART2_RTS\\nUART2_CTSUART3_TX\\nUART3_RX\\nUART5_TX\\nUART5_RX\\nPA_3\\nSPI1_MOSISPI3_SCK\\nSPI2_SCK, 0.808520198) \n", + "8 ([2] “HD44780U (LCD-II) (Dot Matrix Liquid Crystal Display Controller/Driver)” . Accessed July 9, 2021. https://www.sparkfun.com/datasheets/LCD/HD44780.pdf \\n[3] “GitHub - armBookCodeExamples/Directory” . Accessed July 9, 2021. https://github.com/armBookCodeExamples/Directory/ \\n[4] “NUCLEO-F429ZI | Mbed” . Accessed July 9, 2021. https://os.mbed.com/platforms/ST-Nucleo-F429ZI/ \\n[5] “ASCII | Wikipedia” . Accessed July 9, 2021. https://en.wikipedia.org/wiki/ASCII \\n[6] “I2C Serial Interface Adapter Module for LCD” . Accessed July 9, 2021. https://components101.com/modules/i2c-serial-interface-adapter-module \\n[7] “PCF8574 Remote 8-Bit I/O Expander for I2C Bus” . Accessed July 9, 2021. https://www.ti.com/lit/ds/symlink/pcf8574.pdf \\n[8] “Addressing - I2C Bus” . Accessed July 9, 2021. https://www.i2c-bus.org/addressing/ \\n[9] “ST7290 GLCD Pinout, Features, Interfacing & Datasheet” . Accessed July 9, 2021. https://components101.com/displays/st7290-graphical-lcd, 0.781838417) \n", + "7 (List of Figures\\nxxxiv\\nFigure 1.19 Simplified diagram of the Cortex processor family. 33\\nFigure 1.20 Simplified diagram of the Cortex M0, M3, and M4 processors, and details of the \\ncorresponding cores. 34\\nFigure 1.21 Arm Cortex M0, M3, and M4 Instruction Set Architecture (ISA). 35\\nFigure 1.22 STM32F429ZI block diagram made using information available from [9]. 36\\nFigure 1.23 ST Zio connectors of the NUCLEO-F429ZI board. 37\\nFigure 1.24 Hierarchy of different elements introduced in this chapter. 38\\nFigure 1.25 “Smart door locks” built with Mbed contains elements introduced in this chapter. 39\\nFigure 2.1 The smart home system is now connected to a PC. 45\\nFigure 2.2 Website with the program documentation generated with Doxygen. 57\\nFigure 2.3 Detailed description of functions and variables of the program that is available on the website (Part 1/3). 57\\nFigure 2.4 Detailed description of functions and variables of the program that is available on the website (Part 2/3). 58, 0.782111764) \n", + "21 (SPI1_MISOSPI2_CS\\nSPI1_MOSICAN1_RD I2C1_SCL\\nI2C1_SDA CAN1_TD\\nPWM3/1PWM2/1\\nPWM1/1N\\nPWM4/3PWM4/3\\nPWM4/4PWM4/4PB_8\\nPB_9\\nPA_5\\nPA_6\\nPA_7\\nPD_14\\nPD_15\\nPF_12GND\\nADC1/5\\nADC1/6\\nADC1/7DAC1/2\\nFigure 8.5 ST Zio connectors of the NUCLEO-F429ZI board., 0.765687525) \n", + "2 (USAR Tn\\nbxCANnsmcard\\nirDA\\nFIFODigital\\nfilter\\nDACnAPB1 45 MHz (max)AHB1 180 MHzAHB3\\nVDD = 1.8 to 3.6V\\nVSS\\nVCAP1, VCAP2APB2 90 MHzART\\nACCEL/CACHE\\nGPIO POR TtOSC32_I N\\nOSC32_OUTDMA2USB\\nOTG HS\\n8 Streams\\nFIFODMA/\\nFIFO PHY\\nCHROM-AR T\\nDMA2DFIFO\\nFIFO8 Streams\\nFIFODMA1\\nLCD_R[7:0], LCD_G[7:0] ,\\nLCD_B[7:0], LCD_HSYNC,\\nLCD_VSYNC, LCD_DE,\\nLCD_CLKLCD-TFTDMA/\\nFIFO\\nRTC_AF1\\nRTC_AF1\\nRTC 50Hz\\n4KB BXPSRAMLS@ VBAT\\nRTC\\nAWU\\nBackup registerXTAL32 KHz\\nLSStandby\\ninterfaceIWDGXTALOSC 4-26 MHzPOR\\nreset\\nInt\\n@ VDDA @ VDDPVDPOR/PDR BORSupply\\nsupervision@ VDDVDD\\nVoltage regulator\\n3.3 to 1.2VPower\\nmanagement\\nPLL1, 2, 3RC LSRC HS@ VDDA\\nReset\\n& clock\\ncontrol\\nFigure 1.22 STM32F429ZI block diagram made using information available from [9]., 0.807650089) \n", + "6 (38\\nA Beginner’s Guide to Designing Embedded System ApplicationsFigure 1.23 shows how different elements of the STM32F429ZIT6U microcontroller are mapped \\nto the Zio and Arduino-compatible headers of the NUCLEO-F429ZI board. Some other elements \\nare mapped to the CN11 and CN12 headers of the NUCLEO-F429ZI board, as will be discussed in upcoming chapters. Further information on these headers is available from [17].\\nIn this chapter, buttons were connected to the NUCLEO board using pins D2 to D7. From Figure 1.23, \\nit can be seen that those digital inputs can also be referred to as PF_15, PE_13, P_14, PE_11, PE_9, and PF_13, respectively. Throughout this book, many pins of the ST Zio connectors will be used, and they will be referred to in the code using the names shown in Figure 1.23., 0.782175064) \n", + "4 (// commented// See https://os.mbed.com/teams/ST/wiki/STDIO for more information.////==============================================================================\\nCode 8.1 Notes on the PinNames.h file of the NUCLEO-F429ZI board.\\nCode 8.2 and Code 8.3 show the section of PinNames.h regarding PWM pins. For example, on line 4 \\nof Code 8.2, it can be seen that PA_0 is related to PWM2 and channel 1 (channel 1 is indicated by \\nthe 1 that is the penultimate value of line 4), which is used to control the green LED of the RGB LED \\n(see Figure 8.3). This “normal” functionality of PA_0 is shown in Figure 8.5. In line 1 of Code 8.3, it can be seen that PB_0 is related to PWM1 and channel 2, with inverted behavior (ultimate value 1 of line 1). Inverted behavior means that a logic true is set by a 0 V value, as was explained above. This functionality is also shown on Figure 8.5.\\n1\\n23456789\\n10111213141516171819202122//*** PWM ***, 0.788461) \n", + "24 (MSTD_CONSTEXPR_OBJ_11 PinMap PinMap_PWM[] = { {PA_0, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, {PA_1, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 2, 0)}, {PA_2, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 3, 0)}, {PA_2_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM9, 1, 0)}, {PA_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 4, 0)}, {PA_3_ALT0, PWM_9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM9, 2, 0)}, {PA_5, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, {PA_5_ALT0, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 1, 1)}, {PA_6, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 1, 0)}, {PA_6_ALT0, PWM_13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_TIM13, 1, 0)}, {PA_7,, 0.765086949) \n", + "10 ({PA_7_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 1, 1)}, {PA_7_ALT2, PWM_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_TIM14, 1, 0)}, {PA_8, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 1, 0)}, {PA_9, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 2, 0)}, {PA_10, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 3, 0)}, {PA_11, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 4, 0)}, {PA_15, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_P\\nP, GPIO_NOPULL, GPIO_AF1_TIM2, 1, 0)}, \\nCode 8.2 Notes on the PinNames.h file of the NUCLEO-F429ZI board.\\nIt can be seen that PWM functionality is available as alternative functionality in more pins indicated as, 0.779603779) \n", + "17 (101112131415161718192021222324252627282930313233343536373839404142424344454647484950 {PB_0, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 4, 1)}, {PB_0_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 3, 0)}, {PB_0_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 2, 1)}, {PB_1, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 3, 1)}, {PB_1_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 4, 0)}, {PB_1_ALT1, PWM_8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_TIM8, 3, 1)}, {PB_3, PWM_2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM2, 2, 0)}, {PB_4, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 1, 0)}, {PB_5, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 2, 0)}, {PB_6, PWM_4, STM_PIN_DATA_EXT(STM_MODE_AF_PP,, 0.772038043) \n", + "3 (337 , 388 , 455 , 506 , 508 \\n preprocessor directive 217 \\n processor xvi, xxii, xxvi, 33–35, 37, 38, 41, 44, 124 , 353 , 420 , 439 \\n project management 501 \\n Proyecto CIAA xiii, xxiii, xxiv, 443 \\n pull-down resistor 14, 23, 55, 111 \\n pull-up resistor 14, 15, 92, 253 , 255 , 521 , 522 \\n Pulse-Code Modulation (PCM) 354 \\n pulse-width modulation xxvii, 342 , 343 , 345 , 347 –351 , 353 –357 , 360 –362 , \\n 364 –367 , 379 , 380 , 383 –385 , 552\\nR Real Time Clock (RTC) 126 , 132 , 133 , 149 , 153 , 155 , 160 , 167 , 181 , 182 , 193 , 393 , 396 \\n reference operator 151 , 153 , 156 , 261 , 311 , 439 \\n relay module 296 , 299 , 301 , 336 –339 , 506 , 508 , 510 , 514 –516 , 530 \\n repository xxv, xxvi, xxvii, 10, 387 , 388 , 393 , 413 –415 , 416 , 417 , 503 , 546 \\n requirements 2, 497 , 498 , 501 –506 , 510 , 511 , 521 , 522 , 533 , 545 –548 \\n responsiveness 97 \\n RGB LED 342 –345 , 348 –350 , 356 , 357 , 360 –364 , 370 , 373 , 374 , 383 –385 \\n rising edge interrupts 320 , 323 , 324, 0.791497) \n", + "18 (Chapter 12 | Guide to Designing and Implementing an Embedded System Project\\n553 References\\n[1] “NUCLEO-F429ZI | Mbed” . Accessed July 9, 2021. \\nhttps://os.mbed.com/platforms/ST-Nucleo-F429ZI/#zio-and-arduino-compatible-headers \\n[2] “GitHub - armBookCodeExamples/Directory” . Accessed July 9, 2021. https://github.com/armBookCodeExamples/Directory \\n[3] Pham, H. (1999). Software Reliability. John Wiley & Sons, Inc. p. 567. ISBN 9813083840., 0.768167377) \n", + "9 (Preface\\nxx10A250V AC 10A 125V ACCU S\\n10A 0VDC 10A VDC 32 8\\nSRD-05VDC-SL- CCQCRSONGLE\\n10A250V AC 10A 125V ACCU S\\n10A 0VDC 10A VDC 32 8\\nSRD-05VDC-SL- CCQCRSONGLE\\n2 Relay ModuleK2 K1\\nJD-VCC VCC GND GND IN1 IN2 VCCR3 R2D2 D2Q2 Q1\\nIN2 IN1\\nR4 R1+ +\\nB1810\\n817C\\nGB1810\\n817C\\nG\\n1982A 12381H2FPD-270A\\nSolenoid valve External 12V\\nPower source\\nGND12\\n12V\\nAC POWER Adapte r\\nInput 240 VCA\\nOutpur 12V CC 2A\\nErPAri\\nHL-69\\nMoisture\\nsensor\\nEPARIDO-LED\\nAO DO GND VCC\\nPWR-LED\\n+\\n+\\n--\\n--\\n+\\n+\\n--\\n--123456789101112131415161718192021222324252627282930f g\\nh i\\njf g\\nh i\\nja b\\nc d\\nea b\\nc d\\ne123456789101112131415161718192021222324252627282930(Relay IN1)\\ndPF2_5V GND\\n5V\\nGNDNUCLEO-F429Z\\nI\\n32F429ZIT6UAR\\nM\\n7B776 VQPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n12000K620 Y DGKYDKMS-1102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717\\n3.3V\\nGNDD4 to D7D8,D9CN9 CN8\\nCN7CN10Relay module\\nCN9\\nPF 9_\\nPF 7_\\nPF 8_\\nPG 1_(Mode)(How Often)(How Long)(Moisture)COM11NO\\nA3\\nVDDVSS VORSRWED0D1D2D3D4D5D6D7A K11 6, 0.7817837) \n", + "12 (outputs, some fixed and some selectable. \\nWaRning: The selectable outputs should be configured as indicated in Figure 4.7. Otherwise, some modules may be harmed. \\nGND 3V3GND V53V3 5V\\n3V3 5VVoltage\\nselectorsOutput\\nPowerFixed\\n5V\\nFixed\\n3.3VInput\\nPower\\noptions5V\\nMini\\nUSB-B\\n7 to 12 V\\nJackSelectable\\n5V or 3.3VSelectable\\n5V or 3.3V\\nFigure 4.7 Diagram of the MB102 module.\\n4.2.2 T est the Operation of the Matrix Keypad and the RTC\\nThis subsection explains how to load a program onto the STM32 microcontroller in order to test if the matrix keypad that has been connected is working properly. It will also show how to configure the RTC of the STM32 microcontroller. The serial terminal will display the keys that are pressed on the matrix keypad, and the PC keyboard will be used to configure the date and time of the RTC. The .bin file of the \\nprogram “Subsection 4.2.2” should be downloaded from the URL available in [4] and dragged onto the NUCLEO board., 0.774262786) \n", + "19 (M_14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_TIM14, 1, 0)}, \\n {NC, NC, 0}\\n}; \\nCode 8.3 Notes on the PinNames.h file of the NUCLEO-F429ZI board., 0.766855717) \n", + "14 ([10] “ST7920 Chinese Fonts built in LCD controller/driver” . Accessed July 9, 2021. https://pdf1.alldatasheet.es/datasheet-pdf/view/326219/SITRONIX/ST7920.html, 0.773805916) \n", + "22 (422\\nA Beginner’s Guide to Designing Embedded System Applications(Relay GND)(Relay VCC)\\nNUCLEO-F429Z\\nI\\n32F429ZIT6UARM\\n7B776 VQPHL 7B 7213e412000K620 Y12000\\nK620 Y\\n12000K620 Y DGKYDKMS-1102NL1706C\\nSTM32F103CBT6\\ne393701GH218CHN\\nST890C\\nGK717CN8\\n+\\n+\\n--\\n--\\n+\\n+\\n--\\n--123456789101112131415161718192021222324252627282930f g\\nh i\\njf g\\nh i\\nja b\\nc d\\nea b\\nc d\\ne123456789101112131415161718192021222324252627282930\\nMQ-2\\nGas sensor\\n-2MQ\\nGND5V\\nRGB LEDGND 3V3GND V53V3 5V\\n3V3 5VMB-102CN9\\nCN7CN10GND\\n3.3VPotentiometer\\n5V\\nGNDA1Temperature\\nsensorLM35\\n3.3V\\n5V\\nGNDGNDHV1HV2HV\\nLVHV3\\nLV3LV3 LV1HV4\\nLV4LV4 LV2GND\\nGND\\nGNDVCCVORSR/WEDBDBDBDBDBDBDBDB01234567\\nNCPSB RSTVOUTBLABLK\\n1 20A0PG 0_10KΩ GND 5V25V2uF 220\\n25V2uF 220\\n25V2uF 220PIR\\nsensor\\nRed\\nGND\\nBlue\\nGreenPE 12_(Gas)\\nPF 9_\\nPF 7_\\nPF 8_\\nPG 1_(Dir1LS)\\n(Dir1)\\nPE 6_(Audio)\\n(DirLS)2\\n(Dir)2\\nPB 4_\\nPD 12_\\nPA0_(Red)(Blue)(Green)\\nLDRL 35M\\nPC 9_Buzzer\\n5V\\nDO1033.3V\\nSD card and\\nSD card readerGND\\nA\\nB\\nC\\nD871\\n42\\n53\\n6\\n9\\n0 #\\n5151\\n10K\\nJAPANFCCvRKingston\\n1\\nSDCS/32GB, 0.765655637) \n", + "23 (GPIO_AF9_TIM13, 1, 0)}, {PA_7, PWM_1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF1_TIM1, 1, 1)}, {PA_7_ALT0, PWM_3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_TIM3, 2, 0)},, 0.765156627) \n", + "11 (1\\n23456789\\n101112typedef struct{ int address; char data; bool displayPinRs; bool displayPinRw; bool displayPinEn; bool displayPinA; bool displayPinD4; bool displayPinD5; bool displayPinD6; bool displayPinD7;} pcf8574_t;\\nCode 6.23 New private data type used to implement the control of the LCD pins using the PCF8574 LCD module. \\nA private variable of type pcf8574_t is declared in display.cpp, as shown in Code 6.24.\\n1static pcf8574_t pcf8574;\\nCode 6.24 Declaration of a private variable of type pcf8574_t. \\nThe implementation of displayInit() is shown in Code 6.25 and Code 6.26. In line 3 of Code 6.25, \\ndisplay.connection is assigned and in line 5 it is evaluated to establish if it is equal to \\nDISPLAY_CONNECTION_I2C_PCF8574_IO_EXPANDER. If so, pcf8574.address and pcf8574.data are, 0.779199779) \n", + "16 (152\\nA Beginner’s Guide to Designing Embedded System Applications1\\n23456789\\n10111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364case 's':case 'S': struct tm rtcTime; int strIndex; uartUsb.write( \"\\r\\nType four digits for the current year (YYYY): \" , 48 );\\n for( strIndex=0; strIndex<4; strIndex++ ) { uartUsb.read( &str[strIndex] , 1 ); uartUsb.write( &str[strIndex] ,1 ); } str[4] = '\\0'; rtcTime.tm_year = atoi(str) - 1900; uartUsb.write( \"\\r\\n\", 2 );\\n uartUsb.write( \"Type two digits for the current month (01-12): \", 47 );\\n for( strIndex=0; strIndex<2; strIndex++ ) { uartUsb.read( &str[strIndex] , 1 ); uartUsb.write( &str[strIndex] ,1 ); } str[2] = '\\0'; rtcTime.tm_mon = atoi(str) - 1; uartUsb.write( \"\\r\\n\", 2 );\\n uartUsb.write( \"Type two digits for the current day (01-31): \", 45 );, 0.773067594) \n", + "20 (2 (The same elements are used as in Chapter 1.) –\\n3LM35 temperature sensor 1\\n10 kΩ potentiometer 2\\nMQ-2 gas sensor 1\\n5V buzzer 1\\nResistors: 100 Ω, 150 Ω, 330 Ω, 1 kΩ, 10 kΩ, 47 kΩ, 100 kΩ \\n(100 kΩ are used in this chapter and the other resistors in different chapters. See note below.) 10 of each value\\nJumper wires (male–female) 80\\n4Matrix keypad (4 × 4) 1\\n90-degrees 2.54 mm (.1”) pitch pin header 40\\nMB102 breadboard power supply \\n(One is used in this chapter and the other in Chapter 7.) 2\\nUSB–mini-USB cable 2\\n5BC548C NPN transistor (One is used in this chapter and the other in Chapter 8.) 2\\n6Character-based LCD display 20 × 4, based on HD44780 1\\nI2C PCF8574 expander 1\\n10 kΩ trimpot 1\\nBidirectional logic level converter 1\\nJumper wires (female–female) 40\\nGraphic LCD display, based on ST7920 1, 0.766771555) \n", + "13 (TIM / PWMn\\nTIMnTIM9\\nUSAR TnPort P [15:0] t\\nwith t =A to KArm Cortex-M4\\n180 Mhz\\nFPUCCM data RAM 64 KB\\nD-BUSNVICMPU\\nD-BUS\\nD-BUSArm Cortex-M4\\nProcessorETMJTAG & SW\\nEthernet MAC\\n10/100MII or RMII as AF\\nMDIO as AFExternal memory controller (FMC)\\nSRAM, SDRAM, PSRAM,\\nNOR Flash, PC Card, NAND Flash\\nUSB\\nOTG FSCamera\\ninterface2x\\n1MB Flash\\nSRAM\\n112, 16 & 64 KBRING\\nFIFOFIFO\\nPHY\\n16b\\n16b\\n16b\\nsmcard\\nirDA\\nSD, SCK, FS, MCLK as AFSPIn\\nADC1Temperature sensor\\nADC2I F\\nADC3SAI1APB2 90 MHzFIFO\\nTIMnWWDG\\n16b1 channela sAF\\nwith n = 13 or 144 channels, ETR as AF\\nwith n = 3 or 44 channels, ETR as AF\\n2 channels asAF4 channels\\nMOSI/SD, MISO/SD_ext,\\nSCK/CK, NSS/WS, MC K\\nasAFwith n = 2 or 3RX,T X as AF\\nwith n = 4, 5, 7 or 8\\nSCL, SDA, SMBA asAF\\nwith n = 1, 2 or 3RX,TX, CK, CST, RTS\\nasAFwith n = 2 or 3\\nTX, RXwith n = 1 or 2\\nDAC _OUT asAF n\\nwith n = 1 or 2 ITFTIMnTIMn\\nTIM12TIM5TIM2\\nAHB/APB2DMA2 DMA1\\nAHB/APB1\\nSP/ 2SInnUAR Tn\\nI2C /SMBUSn16b16b\\n16b32b32b\\nUSAR Tn\\nbxCANnsmcard\\nirDA\\nFIFODigital\\nfilter, 0.77420038) \n", + "\n", + " Score \n", + "5 4.998557 \n", + "0 0.283747 \n", + "15 0.236537 \n", + "1 -0.658202 \n", + "8 -0.959287 \n", + "7 -1.543990 \n", + "21 -2.066066 \n", + "2 -3.935900 \n", + "6 -5.124876 \n", + "4 -5.264961 \n", + "24 -5.368915 \n", + "10 -5.507993 \n", + "17 -5.671560 \n", + "3 -6.078181 \n", + "18 -6.971182 \n", + "9 -7.042024 \n", + "12 -7.134541 \n", + "19 -7.249991 \n", + "14 -7.423570 \n", + "22 -7.483180 \n", + "23 -7.791863 \n", + "11 -8.350111 \n", + "16 -8.951775 \n", + "20 -9.102522 \n", + "13 -9.436647 " + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "scores_for_all_25_documents.sort_values(by=[\"Score\"], ascending=False)" + "scores_for_all_25_documents = pd.DataFrame({\"Received Texts\": twenty_five_closest_texts, \"Score\": scores})\n", + "scores_for_all_25_documents.sort_values(by=[\"Score\"], ascending=False)\n" ] }, {