完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我现在正在实习,需要你们的帮助。我的长期目标是用块换向控制无刷直流电动机的速度。模拟的话,一切都完成了,我将调整我的Simulink模型来工作在一个C。我正在使用的换流方案是硬斩波,即,两个MOSFET的一个阶段在互补模式切换,两个MOSFET的另一个阶段也切换互补模式BU。T与第一相互补。第三阶段暂时“关闭”(即两个MOSFET都是开放的)。我附上了一个清晰的方案,我用的是什么硬件?一个定制的ECU与DSPIC33 EP256MC506。我怎么能做到这一点呢?- 1。作为互补模式,总是有一个MOSFET打开,一个关闭,我需要PWM HS输出覆盖暂时覆盖输出的一个阶段。2。请看第14节。文档的高速PWM可以在IOCONX寄存器中找到轮询和POLH极性位。这些位决定了PWMXL和PWMXH引脚是否为高电平或低电平。在一个相位的另一个相位上的互补设置将允许两个相位的互补驱动。我的两个问题:1。PWM HS输出重写的文档有点模糊。它解释了要设置四位,位3到0,但是预定义值是“[1 2 3 ]。我想我需要做的是每一个PWM(1到3)创建一个四位二进制数,并将其转换为十进制,然后代表三个条目之一。对吗?(也有一个排字在线)“位0:PWMxH”,我想它应该说“PWMXL”2。如果我提出的方法是正确的,我需要在运行时切换轮询和POLH位,但在Simulink的高速PWM块中找不到那个选项。这将很快在一个更新或如何我可以实现互补模式之间的两个阶段。
以上来自于百度翻译 以下为原文 Hello everyone, I am currently doing an internship and need your assistance. My long term goal is to control the speed of a BLDC motor using block commutation. Simulation-wise everything is finished and I am about to adjust my Simulink model to work on a µC. The commutation scheme I am using is hard chopping, i.e. that two MOSFETs of one phase are switching in complementary mode, the two MOSFETs of another phase are also switching in complementary mode but complementary to the first phase. The third phase is temporarily "turned off" (i.e. both MOSFETs are open). I have attached an image clarifying the scheme. What hardware am I using? - A custom built ECU with the dsPIC33EP256MC506. How I think this can be achieved? - 1. As in complementary mode there is always one MOSFET opened and one closed I would need the PWM HS Output Override to temporarily override the output for one phase. 2. Looking at section 14. Highspeed PWM of the documentation one can find the POLL and POLH polarity bits in the IOCONx register. Those bits decide if the PWMxL and PWMxH pins are active high or active low. Having the complementary setting in one phase towards the other would allow the complementary drive of two phases. My two questions: 1. The documentation of the PWM HS Output Override is a bit vague. It explains there are four bits to be set, bit 3 to 0, yet the predefined value is "[1 2 3] ". I guess what I need to do is for every PWM (1 to 3) to create a four bit binary number and convert it to a decimal which then represents one of the three entries. Is that right? (also there is a typo in the explenation at line "bit 0: PWMxH" I think it should say "PWMxL") 2. If my proposed approach is correct I would need the option to switch the POLL and POLH bits during runtime yet I can not find that option in the Highspeed PWM block in Simulink. Will this soon be possible in an update or how can I achieve complementary mode between two phases. Thanks in advance Moritz Attached Image(s) |
|
相关推荐
5个回答
|
|
再次问好鲁宾和其他人观看,经过考虑,我愿意尝试写IoCOX注册直接,因为我目前没有看到任何其他选项。接下来的是一道问题的墙,但我保证我事先已经充分了解了我需要进一步帮助的一点。所以请考虑所有相关的问题。你说你担心影响错误设置的行为。如果我总是对FLTDAT位写入相同的值(IOCONX寄存器中的唯一位,我不允许在运行时改变),这难道不重要吗?根据文档,其他位可能在运行时发生变化。我认为在IOCONX寄存器中改变比特不承担任何风险,因为PWM HS输出覆盖块在某种程度上也会影响IOCONX寄存器中的Ovrnh、Ovrnl和OVRDAT位。这似乎是可能的。如果我知道寄存器的名称(ICON1到ICON3)和我想写入的值,那么通过C函数调用块访问寄存器会是什么样子?C函数调用块的小描述对我没有帮助。我还发现了IOCONX寄存器中的交换位,这将产生期望的交换PWMX管脚逻辑的结果。这是否在可执行性方面改变了,还是对故障设置有影响?此外,我有一个关于写入IOCONX寄存器的问题。文档说明IOCONX和FCLCONX寄存器是写保护的。如果我想写这些寄存器,我需要先把它们解锁,或者1。将0xABCD和0x4321的两个连续值写入到pWMKEY寄存器中或2。将FCOSSEL的PWMLIK配置位设置为0。我的问题是:关于1。每次更改ICONX寄存器时,都必须这样做吗?还是在程序初始化过程中只做一次?关于2。根据文档取决于设备内存大小,您可以获得FCOSSEL寄存器的地址。如果我错了,请纠正我,但我想你可以用编辑IOCOX寄存器的方式编辑这个寄存器(只是没有解锁过程)?再一次,对不起许多问题,但我将非常感谢!莫里兹
以上来自于百度翻译 以下为原文 Hello again Lubin and everyone else watching, After consideration I am willing to try writing to the IOCONx register directly as I currently don't see any other options. What follows is a wall of questions but I assure that I have well informed myself beforehand to a point where I need further assistance. So please consider all questions as relevant. You said you worry about impacting the behavior of the fault settings. Wouldn't this be irrelevant if I always write the same value to the FLTDAT bits (the only bits in the IOCONx register I am not allowed to change during runtime)? According to the documentation the other bits might be changed during runtime. I would say changing bits in the IOCONx registers doesn't bear a risk as the PWM HS Output Override block somehow also influences the OVRENH, OVRENL and OVRDAT bits in the IOCONx registers. So it seems to be possible. How would accessing the registers through a C Function Call block look like if I know the name of the register (IOCON1 to IOCON3) and the value I want to write to it? The small description of the C Function Call block does not help me enough. I have also found the SWAP bit in the IOCONx registers which would yield the desired result of swapping the logic of the PWMx Pins. Does this change things in regard of implementability or do you still see an influence to the fault settings? Furthermore I have a question about writing to the IOCONx registers. The documentation states that the IOCONx and the FCLCONx registers are write-protected. If I want to write to these registers I need to unlock them first either by 1. writing two consecutive values of 0xABCD and 0x4321 to the PWMKEY register or by 2. setting the PWMLOCK configuration bit of FOSCSEL to 0. My questions are: In regard to 1. Do I have to do this every time I change the IOCONx registers or only once in the initialization process of my program? In regard to 2. According to the documentation depending on the Device Memory Size you get your address for the FOSCSEL register. Correct me if I'm wrong but I guess you can edit this register the same way you edit the IOCONx registers (just without the unlocking process)? Again, sorry for the many questions but I will be so thankful! Moritz |
|
|
|
嗨,莫里兹,PWMLock没有被BuBSET默认设置,因此你可以修改寄存器而不使用解锁序列。附上的是一个示例模型,它试图模仿你在第一个帖子中显示的图形,只使用可用的块。鲁宾。
SMOX(47.07 KB)下载34次 以上来自于百度翻译 以下为原文 Hi Moritz, PWMLock is not set by default by the blockset, thus you could modify registers without using the unlock sequence. Attached is an example model which try to mimic the figure you shown in your first post, using available blocks only. Lubin Attached Image(s) Attachment(s) Moritz_PWM.slx (52.46 KB) - downloaded 46 times Moritz_PWM_R2014b.slx (47.07 KB) - downloaded 34 times |
|
|
|
感谢鲁宾的回答和努力创建一个示例模型。我尝试了你的模型,它仍然没有产生在我的第一个帖子显示的那种信号。然而,这不是问题,因为在你发布模型之前的几天里,我已经成功地创造了想要的信号。现在我将通过回答我发布的问题来发布我的发现。正如我在前一篇文章中所说的,我想通过C函数调用块直接编辑IOCONX寄存器。通过这种方式,我可以改变交换位,从而切换高侧和低侧PWM的信号。起初,我不知道如何设置C函数调用块,但我发现了一个有用的指南在安装目录下的DOCS称为MPLABA BuffStIsSimulink .PDF。我将很快总结出必要的步骤:1。用你想使用的C函数代码创建一个.c文件。打开模型配置参数CTRL+E3。导航到代码生成/自定义代码。在附加的构建信息下,将.c文件添加到源文件。4。插入一个C函数调用块,打开它,检查解析用户文件以列出可用的函数5。重新打开磁盘6.从下拉菜单中选择C函数。块输入和输出应该被正确地设置,另一个问题是,正如鲁宾已经说过的,PWMLROK默认设置为关闭。我也意识到,当浏览任何模型生成的代码时。在*MyMyNo.*.Ma..c文件中找到一行后,我知道我可以直接编辑ICONX寄存器而不需要任何解锁序列。所以现在是编写编辑ICONX寄存器的代码的时候了。我发现了两种方法来实现这一点。首先,在一个模型中,我使用了PWM HS输出覆盖块,建立了模型并查看生成的代码。我发现下面的行:我使用这个信息来创建我自己的PWM HS输出覆盖函数,除了改变交换位之外。这是C代码:唯一要做的就是在正确的位置用正确的位来填充函数。我在Simulink中这样做,并在图形中显示。编辑ICONX寄存器的第二种方法是直接调用寄存器位,例如将ICON1寄存器中的交换位设置为1 I型,以找到所有可用的合法位名称,您必须为单片机找到头文件。我的例子是p3EP256MC506.h在C:程序文件(x86)Microchip xC16v1.33\dSPIC33 eh。使用搜索功能,您可以找到ICONX寄存器和所有的位名称,如图中所示。希望这能帮助你们中的一些人。莫里兹。
以上来自于百度翻译 以下为原文 Thank you Lubin for your reply and effort to create an example model. I tried your model and it still does not create the kind of signals shown in my first post. However this is no problem as just a few days before you posted your model I have had success creating the desired signals. I will now post my findings by answering the questions I posted. As I said in a previous post I wanted to edit the IOCONx registers directly through a C Function Call block. That way I can change the SWAP bit so the signals for the high-side and low-side PWMs are switched. At first I didn't know how to set up the C Function Call block but I found a helpful guide in the installation directory under docs called MPLAB_Blockset_Simulink.pdf. I will quickly summarize the necessary steps: 1. create a .c file with the C function code you want to use 2. open the Model Configuration Parameters, Ctrl+E 3. navigate to Code Generation / Custom Code. Under Additional build information add the .c-file to the Source files. 4. insert a C Function Call block, open it, check Parse user file to list functions available 5. re-open the block 6. select your C function from the dropdown menu. The block inputs and outputs should be set correctly Another question I have had was As Lubin has already said the PWMLOCK is set to OFF by default. I also realized that, when looking through the generated code of any model. In the *model_name*_main.c file one can find the line #pragma config PWMLOCK = OFF After finding this I knew that I could directly edit the IOCONx registers without any unlocking sequence. So now it was time to write the code for editing the IOCONx registers. I have found two ways to achieve this. First: In one model I used the PWM HS Output Override block, built the model and looked through the generated code. I found the following lines: uint16_T register tmp; tmp = IOCON1; tmp = ( (tmp ^ ((uint16_T) 13U << 6)) & 0x3C0) ^ tmp;/* Set bits [6 7 8 9] accordingly (OVERENH, OVRENL and OVERDATH, OVERDATL) */ IOCON1 = tmp; I used this information to create my own PWM HS Output Override function with the addition to change the SWAP bit. This is the C-code: /* Include for pic 33E */ #include void config_PWM(int ioconbits1) { int register tmp; tmp = IOCON1; tmp = ( (tmp ^ ((int) ioconbits1)) & 0x3C2) ^ tmp;/* Set bits [2 6 7 8 9] accordingly (SWAP, OVRDAT0, OVRDAT1, OVRENL, OVRENH) */ IOCON1 = tmp; } The only thing left to do is to feed the function with the right bits at the right spot. I did this in Simulink and is shown in the graphics. The second way to edit the IOCONx registers is by calling the register bits directly, e.g. to set the SWAP bit in the IOCON1 register to 1 I type IOCON1bits.SWAP = 1; To find all available and legit bit names you have to find the header file for your microcontroller, in my case the p33EP256MC506.h under C:Program Files (x86)Microchipxc16v1.31supportdsPIC33Eh. Using the search function you find the IOCONx registers and all the bit names as shown in the picture. I hope this helps some of you. Moritz Attached Image(s) |
|
|
|
你好,莫里兹,谢谢分享你的解决方案。你有任何可能附加你的测试模型文件+附加C文件吗?我会有兴趣测试和更好地理解你正在寻找的信号。多谢,鲁宾。
以上来自于百度翻译 以下为原文 Hi Moritz, Thanks for sharing your solution. Would you have any possibility to attach your test model file + added C file as is. I would be interested to test & better understand signals you are looking for. Many thanks, Lubin |
|
|
|
你好,鲁宾,附件是相关文件,用MCLv2莫里兹测试。
以上来自于百度翻译 以下为原文 Hi Lubin, attached are the relevant files, tested with the MCLV2. Moritz Attached Image(s) Attachment(s) PWM_block_commutation.zip (35.17 KB) - downloaded 40 times |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1929 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3175 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2227 浏览 5 评论
736浏览 1评论
619浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
507浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
633浏览 0评论
530浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 11:11 , Processed in 1.791159 second(s), Total 86, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号