完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,
我的任务是拿出一个正向计数器来在CW和CCW方向上运行电机。 我需要上来 设计时设置为零的计数器将处于“中心位置”然后我可能想要改变方向 并以正(CW)或负方向(CCW)计算电机步数。 我熟悉updown计数器但只有零和正数。 对于这个设计,我可能想告诉柜台 通过告诉-6减去6。 或者加6说+ 6。 这对我来说似乎有点困难。 谢谢, 加里奥尔森 以上来自于谷歌翻译 以下为原文 Hi, I am tasked to come up with a positon counter to run a motor in CW and CCW direction. I need to come up with a design where the counter when set to zero will be at a "Center position" Then I may want to change direction and count motor steps either in positive(CW) or negative direction(CCW). I am familiar with updown counters but only zero and positive numbers. for this design I may want to tell the counter to subtract let say 6 by telling it -6. or add 6 say + 6. This seems a little harder to do to me. Thanks, Gary Olson |
|
相关推荐
4个回答
|
|
尝试使用签名类型。
这些将是两个补码,它们允许您可视化负数。还要记住,负数是一种幻觉; 没有这样的东西;-)只有方向和自然数(即> = 0)。 所以你要做的是将其中一个位指定为方向指示,比如说MSB。 一种选择是仅将此位用于符号,将其余位用作幅度。 这被称为一个补码,它有两个问题:它有两个零,即0.0和1.0,在硬件中实现它更复杂。 第二种选择是将-2 ^(N-1)值分配给MSB,并将其余位视为正。 这被称为二进制补码,实现的逻辑是你所期望的(即0-1给你所有的等),它只有一个零即全零模式。 - 如果提供的信息有用,请将答案标记为“接受为解决方案”。给予您认为有用且回复的帖子。 在原帖中查看解决方案 以上来自于谷歌翻译 以下为原文 Try using signed types. These will be two's complement and they allow you to visualize negative numbers. Also keep in mind, negative numbers are an illusion; no such thing ;-) Only direction and natural numbers (ie >= 0). So what you do is assign one of the bits as direction indication, say MSB. One option is to use this bit only for sign and the rest of the bits as magnitude. This is called one's complement and it has two issues: it has two zeros ie 0.0 and 1.0 and it's more complicated to implement it in hardware. The second option is to assign -2^(N-1) value to the MSB and treat the rest of the bits as positive. This is called two's complement and the logic to implement is what you would expect (ie 0-1 gives you all ones etc) and it has only one zero ie the all zero pattern.- Please mark the Answer as "Accept as solution" if information provided is helpful. Give Kudos to a post which you think is helpful and reply oriented.View solution in original post |
|
|
|
尝试使用签名类型。
这些将是两个补码,它们允许您可视化负数。还要记住,负数是一种幻觉; 没有这样的东西;-)只有方向和自然数(即> = 0)。 所以你要做的是将其中一个位指定为方向指示,比如说MSB。 一种选择是仅将此位用于符号,将其余位用作幅度。 这被称为一个补码,它有两个问题:它有两个零,即0.0和1.0,在硬件中实现它更复杂。 第二种选择是将-2 ^(N-1)值分配给MSB,并将其余位视为正。 这被称为二进制补码,实现的逻辑是你所期望的(即0-1给你所有的等),它只有一个零即全零模式。 - 如果提供的信息有用,请将答案标记为“接受为解决方案”。给予您认为有用且回复的帖子。 以上来自于谷歌翻译 以下为原文 Try using signed types. These will be two's complement and they allow you to visualize negative numbers. Also keep in mind, negative numbers are an illusion; no such thing ;-) Only direction and natural numbers (ie >= 0). So what you do is assign one of the bits as direction indication, say MSB. One option is to use this bit only for sign and the rest of the bits as magnitude. This is called one's complement and it has two issues: it has two zeros ie 0.0 and 1.0 and it's more complicated to implement it in hardware. The second option is to assign -2^(N-1) value to the MSB and treat the rest of the bits as positive. This is called two's complement and the logic to implement is what you would expect (ie 0-1 gives you all ones etc) and it has only one zero ie the all zero pattern.- Please mark the Answer as "Accept as solution" if information provided is helpful. Give Kudos to a post which you think is helpful and reply oriented. |
|
|
|
除了符号/幅度和二进制补码之外,您还可以考虑偏移二进制。
在这种情况下,计数器是无符号的,您的中心位置是1/2刻度(MSB 1,其他位为零)。 实际上,除了复位条件之外,这种方法应该构建几乎与2的补码方法相同的硬件。 - Gabor 以上来自于谷歌翻译 以下为原文 In addition to sign/magnitude and two's complement, you might consider offset binary. In that case the counter is unsigned and your center position is 1/2 scale (MSB one, other bits zero). In reality this method should build hardware that is almost identical to the 2's complement approach, with the exception of the reset condition. -- Gabor |
|
|
|
嗨Gabor,
感谢您的答复。 现在我决定使用无符号方式,中途为零值。 在我开始工作后,我计划尝试按照签名方式设计计数器。 谢谢, 加里 以上来自于谷歌翻译 以下为原文 Hi Gabor, Thank you for the response. Right now I decided to use the unsigned way with half way up being my zero value. After I get that working I plan to try to design the counter the signed way. Thank You, Gary |
|
|
|
只有小组成员才能发言,加入小组>>
2396 浏览 7 评论
2811 浏览 4 评论
Spartan 3-AN时钟和VHDL让ISE合成时出现错误该怎么办?
2278 浏览 9 评论
3356 浏览 0 评论
如何在RTL或xilinx spartan fpga的约束文件中插入1.56ns延迟缓冲区?
2445 浏览 15 评论
有输入,但是LVDS_25的FPGA内部接收不到数据,为什么?
781浏览 1评论
请问vc707的电源线是如何连接的,我这边可能出现了缺失元件的情况导致无法供电
558浏览 1评论
求一块XILINX开发板KC705,VC707,KC105和KCU1500
405浏览 1评论
1985浏览 0评论
704浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 05:57 , Processed in 1.375589 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号