基于MEG64的LED跑马灯程序实现与初始化代码

版权申诉
0 下载量 16 浏览量 更新于2024-10-11 收藏 22KB RAR 举报
资源摘要信息:"本文档名为 'key_new1.rar_Meg64',涉及的主要技术点为 'meg64',这是一款常用于嵌入式系统开发的微控制器。文档描述了一个特定的LED跑马灯程序,并提到了包含一部分初始化程序代码。LED跑马灯是一种常见的微控制器入门级项目,它通过编程使得LED灯依次点亮,形成类似跑马灯的视觉效果,通常用于学习和演示微控制器的基本输入输出操作。" 知识点如下: 1. 微控制器(MCU)基础 微控制器是将微处理器核心和周边设备集成到单个芯片上的集成电路,常用于控制特定的硬件设备。本例中提到的 'meg64' 可能指的是Microchip Technology公司生产的PIC18F67K90系列微控制器。这类微控制器具备了多种功能,如定时器、串行通信等。 2. LED跑马灯项目 LED跑马灯是一种利用LED灯来模拟跑马灯效果的电子项目。在该项目中,LED灯以一定的顺序依次点亮和熄灭,从而形成流动的光效果。这个项目常作为微控制器学习的入门实验。 3. 初始化程序代码 微控制器在执行任何操作之前,需要进行一系列的初始化设置。这包括配置微控制器的输入输出端口(I/O端口)、设置时钟系统、配置中断系统等。初始化代码是保证微控制器正常工作和后续程序顺利运行的基础。 4. PIC18F67K90系列微控制器特点 PIC18F67K90系列微控制器属于Microchip公司的产品,具备以下特点: - 内置闪存程序存储器,方便程序的烧录和更新。 - 具有多种通信接口,包括UART、SPI和I2C等。 - 支持多种中断源,增强实时处理能力。 - 提供多通道模数转换器(ADC),方便模拟信号处理。 5. 编程实践 在开发跑马灯程序时,需要利用C语言或汇编语言对微控制器进行编程。编程过程中会涉及到微控制器的寄存器配置,比如设置I/O端口为输出模式,配置定时器用于控制LED点亮的时间间隔等。 6. 项目开发步骤 开发一个LED跑马灯项目通常包括以下步骤: - 首先设计电路图,决定如何连接LED和微控制器。 - 然后编写初始化代码,确保微控制器的I/O端口和其他模块正常工作。 - 接着编写主程序,控制LED灯的点亮顺序和时间间隔。 - 最后进行调试,确保程序按预期运行,并且效果符合设计要求。 7. 文件压缩包结构 由于文档信息中提到了压缩包文件的名称列表,包括 '***.txt' 和 'key_new',这暗示了源代码或者更详细的说明文档可能被包含在这些文件中。'***.txt' 可能是包含有项目说明、网址信息的文本文件,而 'key_new' 可能是源代码文件、工程文件或者图片等资源。 通过以上的知识点说明,我们可以理解微控制器在跑马灯项目中的应用,以及程序开发过程中需要关注的关键技术点。对于学习嵌入式系统和微控制器编程的开发者而言,该项目是一个很好的实践起点。

import scipy.io import mne from mne.bem import make_watershed_bem # Load .mat files inner_skull = scipy.io.loadmat('E:\MATLABproject\data\MRI\Visit1_040318\\tess_mri_COR_MPRAGE_RECON-mocoMEMPRAGE_FOV_220-298665.inner_skull.mat') outer_skull = scipy.io.loadmat('E:\MATLABproject\data\MRI\Visit1_040318\\tess_mri_COR_MPRAGE_RECON-mocoMEMPRAGE_FOV_220-298665.outer_skull.mat') scalp = scipy.io.loadmat('E:\MATLABproject\data\MRI\Visit1_040318\\tess_mri_COR_MPRAGE_RECON-mocoMEMPRAGE_FOV_220-298665.scalp.mat') print(inner_skull.keys()) # Assuming these .mat files contain triangulated surfaces, we will extract vertices and triangles # This might need adjustment based on the actual structure of your .mat files inner_skull_vertices = inner_skull['Vertices'] inner_skull_triangles = inner_skull['Faces'] outer_skull_vertices = outer_skull['Vertices'] outer_skull_triangles = outer_skull['Faces'] scalp_vertices = scalp['Vertices'] scalp_triangles = scalp['Faces'] # Prepare surfaces for MNE surfs = [ mne.bem.BEMSurface(inner_skull_vertices, inner_skull_triangles, sigma=0.01, id=4), # brain mne.bem.BEMSurface(outer_skull_vertices, outer_skull_triangles, sigma=0.016, id=3), # skull mne.bem.BEMSurface(scalp_vertices, scalp_triangles, sigma=0.33, id=5), # skin ] # Create BEM model model = mne.bem.BEM(surfs, conductivity=[0.3, 0.006, 0.3], is_sphere=False) model.plot(show=False) # Create BEM solution solution = mne.make_bem_solution(model) 运行代码时报错; Traceback (most recent call last): File "E:\pythonProject\MEG\头模型.py", line 24, in <module> mne.bem.BEMSurface(inner_skull_vertices, inner_skull_triangles, sigma=0.01, id=4), # brain AttributeError: module 'mne.bem' has no attribute 'BEMSurface'

147 浏览量

运行代码: import scipy.io import mne from mne.bem import make_watershed_bem import random import string # Load .mat files inner_skull = scipy.io.loadmat('E:\MATLABproject\data\MRI\Visit1_040318\\tess_mri_COR_MPRAGE_RECON-mocoMEMPRAGE_FOV_220-298665.inner_skull.mat') outer_skull = scipy.io.loadmat('E:\MATLABproject\data\MRI\Visit1_040318\\tess_mri_COR_MPRAGE_RECON-mocoMEMPRAGE_FOV_220-298665.outer_skull.mat') scalp = scipy.io.loadmat('E:\MATLABproject\data\MRI\Visit1_040318\\tess_mri_COR_MPRAGE_RECON-mocoMEMPRAGE_FOV_220-298665.scalp.mat') print(inner_skull.keys()) # Assuming these .mat files contain triangulated surfaces, we will extract vertices and triangles # This might need adjustment based on the actual structure of your .mat files inner_skull_vertices = inner_skull['Vertices'] inner_skull_triangles = inner_skull['Faces'] outer_skull_vertices = outer_skull['Vertices'] outer_skull_triangles = outer_skull['Faces'] scalp_vertices = scalp['Vertices'] scalp_triangles = scalp['Faces'] subjects_dir = 'E:\MATLABproject\data\MRI\Visit1_040318' subject = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=8)) # Prepare surfaces for MNE # Prepare surfaces for MNE surfs = [ mne.make_bem_model(inner_skull_vertices, inner_skull_triangles, conductivity=[0.01], subjects_dir=subjects_dir), # brain mne.make_bem_model(outer_skull_vertices, outer_skull_triangles, conductivity=[0.016], subjects_dir=subjects_dir), # skull mne.make_bem_model(scalp_vertices, scalp_triangles, conductivity=[0.33], subjects_dir=subjects_dir), # skin ] # Create BEM solution model = make_watershed_bem(surfs) solution = mne.make_bem_solution(model) 时报错: Traceback (most recent call last): File "E:\pythonProject\MEG\头模型.py", line 30, in <module> mne.make_bem_model(inner_skull_vertices, inner_skull_triangles, conductivity=[0.01], subjects_dir=subjects_dir), # brain File "<decorator-gen-68>", line 12, in make_bem_model File "E:\anaconda\envs\pythonProject\lib\site-packages\mne\bem.py", line 712, in make_bem_model subject_dir = op.join(subjects_dir, subject) File "E:\anaconda\envs\pythonProject\lib\ntpath.py", line 117, in join genericpath._check_arg_types('join', path, *paths) File "E:\anaconda\envs\pythonProject\lib\genericpath.py", line 152, in _check_arg_types raise TypeError(f'{funcname}() argument must be str, bytes, or ' TypeError: join() argument must be str, bytes, or os.PathLike object, not 'ndarray' 进程已结束,退出代码1

147 浏览量

介绍一下这段代码的Depthwise卷积层def get_data4EEGNet(kernels, chans, samples): K.set_image_data_format('channels_last') data_path = '/Users/Administrator/Desktop/project 5-5-1/' raw_fname = data_path + 'concatenated.fif' event_fname = data_path + 'concatenated.fif' tmin, tmax = -0.5, 0.5 #event_id = dict(aud_l=769, aud_r=770, foot=771, tongue=772) raw = io.Raw(raw_fname, preload=True, verbose=False) raw.filter(2, None, method='iir') events, event_id = mne.events_from_annotations(raw, event_id={'769': 1, '770': 2,'770': 3, '771': 4}) #raw.info['bads'] = ['MEG 2443'] picks = mne.pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False) epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=False, picks=picks, baseline=None, preload=True, verbose=False) labels = epochs.events[:, -1] print(len(labels)) print(len(epochs)) #epochs.plot(block=True) X = epochs.get_data() * 250 y = labels X_train = X[0:144,] Y_train = y[0:144] X_validate = X[144:216, ] Y_validate = y[144:216] X_test = X[216:, ] Y_test = y[216:] Y_train = np_utils.to_categorical(Y_train - 1) Y_validate = np_utils.to_categorical(Y_validate - 1) Y_test = np_utils.to_categorical(Y_test - 1) X_train = X_train.reshape(X_train.shape[0], chans, samples, kernels) X_validate = X_validate.reshape(X_validate.shape[0], chans, samples, kernels) X_test = X_test.reshape(X_test.shape[0], chans, samples, kernels) return X_train, X_validate, X_test, Y_train, Y_validate, Y_test kernels, chans, samples = 1, 3, 251 X_train, X_validate, X_test, Y_train, Y_validate, Y_test = get_data4EEGNet(kernels, chans, samples) model = EEGNet(nb_classes=3, Chans=chans, Samples=samples, dropoutRate=0.5, kernLength=32, F1=8, D=2, F2=16, dropoutType='Dropout') model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) checkpointer = ModelCheckpoint(filepath='/Users/XXX/baseline.h5', verbose=1, save_best_only=True) class_weights = {0: 1, 1: 1, 2: 1, 3: 1} fittedModel = model.fit(X_train, Y_train, batch_size=2, epochs=100, verbose=2, validation_data=(X_validate, Y_validate), callbacks=[checkpointer], class_weight=class_weights) probs = model.predict(X_test) preds = probs.argmax(axis=-1) acc = np.mean(preds == Y_test.argmax(axis=-1)) print("Classification accuracy: %f " % (acc))

346 浏览量

**测试电路** .option post RUNLVL=5 post_version=9601 **控制仿真精度以及仿真版本,不加这个没波形 .option probe post ** 设置波形输出 .option method=trap .option interp .option itl4=100 .option gshunt=1e-10 .option S_RATIONAL_FUNC=0 * DDR数据速率设置 .param bitrate = 10000Meg *数据速率 .param freq_clk = 'bitrate/2' *时钟频率,在DDR中,时钟速率是数据 .param UI_period = '1/bitrate' *每一位码元的时间 .param UI_sample = '100' *每一位码元的采样点,用来计算步长 .param tr=30ps tf=30ps td=0.2ns *上升沿,下降沿,延时 .param UI_num = '100' *总的仿真的码元 .param tran_step = 'UI_period/UI_sample' *仿真的步长 .param tran_stop = 'td+UI_num*UI_period' *总的仿真时间 vnd_en nd_en gnd dc 1.1 ** 电源使能 ********** 链路设置 ************ **输入的ibis模型定义 **只在DQ0端输入信号 bdq0_tx r_pu_dq0 r_pd_dq0 DQ0_Link_in ibis_dq0 nd_en r_OutOfIn_dq0 + file = 'h5cnag4nmjr_zfc.ibs' + model = 'RON34ODTOFF' + ramp_fwf=2 ramp_rwf=2 + typ = typ * endfold **S参数定义 **链路S参数 SLink DQ0_Link_in + DQ0_out ** 13-25为输出引脚 + mname = SLink_model .MODEL SLink_model S + TSTONEFILE = channel.s2p + FBASE=10MEGHZ FMAX=12GHZ **接收端ibis设置 * Rank0 bdq0_rx t_pu_dq0 t_pd_dq0 DQ0_out r_ndrot2rx0 +file = 'h5cnag4nmjr_zfc.ibs' +model = 'RONOFFODT120' +ramp_fwf=2 ramp_rwf=2 +typ = typ *********************仿真设置************************ *边沿输入 .PAT start_PAT=b0 r=1 rb=1 .PAT edge_PAT = b00010 r=0 rb=1 .PAT stop_PAT = b0 r=-1 rb=1 P_DQ0 ibis_dmc gnd port=1 dc=0 z0=50 + PAT(1 0 td tr tf UI_period start_PAT edge_PAT stop_PAT) .tran tran_step tran_stop *********************输出设置************************ .probe tran v(DQ0_out) .end网表解释

431 浏览量