完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
嗨,伙计们,
我一直在玩我的2键FOB和接收器,我想把它连接到我的PSoC 1不会很棒。 与我的PSoC相连的是我制作的2个红外波束断路器,它们目前使用的是简单的代码。我想做一个简单的警报。应该是这样的。系统待机;等待武器(钥匙离岸按钮1)&武装;FOB的按钮应该解除是否报警被激活或禁用它,即使它不激活报警。 所以我需要声明一些类似的事情: 扣臂=0; 扣臂=0; 而buttonARM不压,不做任何事,如果它是ARM启动报警 { 做报警的东西,这样做来监视红外波束断路器 如果警报响起的任何理由和buttondisarm按下,禁用报警输出 } IM 100%确定如何实现KEKFOB 任何帮助总是非常感谢。 谢谢 以上来自于百度翻译 以下为原文 Hi guys, Ive been playing around with my 2 button key fob and receiver, and i thought wouldnt it be great to interface it to my Psoc 1. conected to my psoc are 2 ir beam breakers i made, they currently work with a simple bit of code. I was wanting to make a simple alarm. it shoud be like this. system on> wait till armed (button 1 of key fob) > armed> do alarm stuff (already done). button 2 of the fob should disarm the alarm whether the alarm was activated or just to disable it even if it wasnt activated. so do i need to declare something like: buttonarm==0; buttondisarm==0; while buttonarm is not pressed, dont do anything, if it is arm alarm activated { do alarm stuff, have this done to monitor ir beam breakers if the alarm goes off for any reason and buttondisarm is pressed, disable alarm output } im 100% sure on how to implement the keyfob any help is always greatly appreciated. thanks |
|
相关推荐
44个回答
|
|
嗨,我已经通过一些旧的大学项目,我们做了,我遇到了这个代码,使用CAPSENSE,PWM,LCD等。我切断了LCD,CasasSnices等,但我不能修改代码做一些类似的事情吗?
空隙主(空隙){ int alARMARMED= false;int System on = TRUE;int ALMAcActudio=false; (1){ 如果(ALARMAPACTION= = false){ 如果(System on=true){ System on=false; AlalMeMe=假; } 否则,(System on=false){ System on = true} } 如果((System on=TRUE)和AMP;(ALARMAPATION= = FALSE)) 如果(AlalAc激活==false) { AlalMeMe=真; } 否则,(alARMARMED==真){ AlalMeMe=假; } } 如果((System on=TRUE)和AMP;(ALARMASTATION== TRUE)) { 警报活动=真; } 以上来自于百度翻译 以下为原文 Hi, Ive been goign through some old college projects we did and ive come across this code which used capsense, PWM, LCD etc. I cut out the LCD, capasense etc below but could i not modify the code to do something like below? void main (void) { int AlarmArmed=FALSE; int SystemOn=TRUE; int AlarmActive=FALSE; while(1) { if (AlarmActive==FALSE) { if(SystemOn==TRUE) { SystemOn=FALSE; AlarmArmed=FALSE; } Else if (SystemOn==FALSE) { SystemOn=True } } if ((SystemOn==TRUE)&&(AlarmActive==FALSE)) if (AlarmActivated==FALSE) { AlarmArmed=TRUE; } else if (AlarmArmed==TRUE) { AlarmArmed=FALSE; } } if ((SystemOn==TRUE) && (AlarmActivated==TRUE)) { AlarmActive=TRUE; } |
|
|
|
1。我将添加一个键去弹跳函数,并命名两个变量ARMKEY和DISARMKEY,它们是去抖的输入。
2。我将添加两个变量,称为St体制(武装或解除武装)和ALARMSTATE(ALARMYON ON或ALMARYNOTYON) 你可以试着用这些来开发你的程序。 以上来自于百度翻译 以下为原文 1. I would add a key debounce function, and name two variables armKey and disarmKey which were debounced inputs. 2. I would add two variable called systemState (ARMED or DISARMED) and alarmState (ALARM_ON or ALARM_NOT_ON) You can try to use these to develope your program. |
|
|
|
好吧,我反应太慢了。:
现在检查你的程序。 以上来自于百度翻译 以下为原文 OK, I am too slow to reponse. :-( Shall check your program now. |
|
|
|
1。对于其他人理解你的代码,最好是什么变量,哪些是关键输入?int alARMARMED=假;/*密钥INPUT?*/int System on=TRUE;/*TRUE;如果…?*/int alARMcActudio=false;/*IR中断?* / 2。AlarmActivated是什么?
以上来自于百度翻译 以下为原文 1. For others to understand your code, it would be better tto state what are those variables, which are the key inputs? int AlarmArmed=FALSE; /* Key inpput? */ int SystemOn=TRUE; /* TRUE if ....? */ int AlarmActive=FALSE; /* IR broken? */ 2. what is AlarmActivated? |
|
|
|
你好,
是的,你是对的,我基本上打开了这个项目,并把它输入到回复页面。对不起,误会了, 好吧,我看到我发送的代码,只是增加了混乱, 是的,我认为从我的第一篇文章中的要求来看,最好是忽略了发送的代码。 以上来自于百度翻译 以下为原文 HI, Yes, you are quite right, i basically just opened the project and typed it into the reply page here. Sorry for the misunderstanding, ok I see that code i sent in, is just adding to the confusion, yeah basically i think it would probably be best to work from the requirements in my first post, and ignore the code sent in. |
|
|
|
我们需要一个编辑功能!!!!!!!!
你的节目离我的建议很近。它只需要把评论放进去让别人明白你的意思。 一旦你添加了这些评论,人们就可以看到是否有错误。 但我肯定会为键添加DeBung函数。 你需要对红外光束传感器进行一些反跳吗? 以上来自于百度翻译 以下为原文 WE NEED AN EDIT FUNCTION !!!!!! Your program is close to what i suggested. It just need to put comments in so otherS can see what you mean to do. Once you add those comments in , people can see if there are errors or not. But I definely would add the debounce function for the keys. And do you need some kinds of debounce for your IR beam sensor? |
|
|
|
希亚·Lleung
如果它有帮助,我可以给你的项目文件的代码IM引用。 我有点高兴,我的挖掘机翻了个弯。 目前,红外线束断路器正处于使用状态,因为它们是整齐的,我可以把任何东西,开关等提供一个高或低信号。目前可能还不存在DeBug。 谢谢回复 以上来自于百度翻译 以下为原文 hiya Lleung, If it helps i could give you the project files for that code im quoting from. im a little glad that my digging turned somethin up lol. for the moment the IR beam breakers im using are just there as they are neat, i could put anything there, switch etc to provide a high or low signal. debounce might not be neededfor the moment. thanks for replying |
|
|
|
当然,
你可以在这里上传你修改过的项目,不需要100%的正确。 把你的评论放在第一位,人们可以提出错误或改进的建议。 快乐编码。 以上来自于百度翻译 以下为原文 Sure, You can upload your modified project here, doesn't need to be 100% correct. Put your comments there first, people can make suggestion for errors/improvement. Happy coding. |
|
|
|
我想上传的代码中有所有的CopSoSE,LCD的东西,这是一个好一点复杂的IM试图做的事情。我想做的是当我按下FOB按钮A并在按钮B上停止时,代码就运行了。
代码我只是检查输入,使用我们的朋友影子寄存器,并写入和输出到端口1,这是一个LED,指示输出或惊慌状态。 以上来自于百度翻译 以下为原文 the code i was thinking of uploading has all the capsense, lcd stuff in it and is a good bit more complicated that what im trying to do. all i want to do is have the code run when i press button a of the fob and stop on button b, the code i have simply checks inputs, using our friend the shadow register and writes and output to port 1.0 which is an led, indicating an output or alarmed state. |
|
|
|
如果我尝试这样做,它能起作用吗?
我有一个连接到端口1.7的FOB输入,一个我想禁用警报。 空隙主(空隙) 虽然(PRT1)!=0x80)/检查FOB按钮是否未被按下,如果它不运行其余代码?有效不解除保险装置? { 用于报警输入的代码,只需检查是否有某些端口是高的,如果没有声音报警 } 这样的事情能实现吗? 以上来自于百度翻译 以下为原文 what if i tried to do it this way, could it work? i have a fob input connected to port 1.7, the one i want to disable the alarm with void main(void) while ( PRT1 != 0x80) // checks fob button isnt pressed, if it is dont run rest of code? effectively not arming device? { code for alarm inputs, simply checks to see if certain ports are high, if not sound alarm } could something like this be implemented? |
|
|
|
报警系统是状态机的一个很好的例子,经常被用来作为一个例子来介绍“如何”。
从你以前的帖子我可以看出你有意接近这样的设计,所以我建议你完成它: 为当前状态使用变量,并为所有可能的状态加上未知状态的枚举。 为每个状态定义一个状态(一个或多个信号)达到另一个状态。 编程一个循环 第一、收集所有输入信号并设置相应的VAR(这种隔离使系统独立于传感器类型和类似的差异) 第二。输入具有所有可能状态的开关()块,并在每个状态中决定下一个状态。 就是这样 快乐编码 鲍勃 以上来自于百度翻译 以下为原文 An alarm system is a pretty good example for a state-machine and is often used as an example to introduce the "how to"s. From your former posts I can see that you intentionally are approaching to such a design, so I suggest you to complete it: Use a variable for the current state and have an enum for all possible states + an unknown state. Define for each state under which circumstances (one or more signals) another state is reached. Program a loop which 1st. Gathers all input signals and sets corresponding vars (this isolation makes the system independent from sensor-types and similar differences) 2nd. enter a switch () block with all possible states and decide in each state which state comes next. That's it Happy coding Bob |
|
|
|
鲍伯的主意不错。
由于这是一个简单的项目,您可以启动一个新项目而不需要其他所有的比特和碎片。 我仍然认为你需要为你的密钥去弹出,你可以使用DeNoCurter组件和最新的创建者组件包。 有时候,新鲜的开始要容易得多。 以上来自于百度翻译 以下为原文 Bob's idea is good. Since this is a simple project, you can start a new project without all other bits and pieces. I still think you need the debounce for your key, you can use the debouncer component with the latest creator component pack. Sometime it is much easier to start fresh. |
|
|
|
使用开关和外壳,
IVE使用Visual Basic和控制台运行程序,但不使用微控制器, 我认为这有点像: 中断,输入(输入){实例0;++CONT0;中断;案例1:++COUNT1;中断;案例2:++CONTT2;中断;案例3:++CONTT3;BraceCase4: ++CONTT4;BACKE;我确信这对任何做这件事的人来说都是显而易见的,但是我对把它适应我的代码感到有点困惑。 以上来自于百度翻译 以下为原文 using switch and case, ive used this with visual basic and console run programs but not using a microcontroller, It kind of goes, i think: int count0; int count1; int count2; int count3; int count4; switch(input) { case 0: ++count0; break; case 1: ++count1; break; case 2: ++count2; break; case 3: ++count3; break case 4: ++count4; break; im sure this is really obvious to anyone whos done this but im a little confused about adapting it to my code |
|
|
|
以下是提示:
交换机(系统状态) { DISARMD案: 检查键; 如果ARMKEY被压缩 清除所有输出; 将系统状态更改为武装 断裂; 案例武装: 在这里应该做什么* 断裂; 违约: 在这里应该做什么* } 以上来自于百度翻译 以下为原文 here is the hint: switch (systemState) { case DISARMD: check keys; if armKey presssed clear all outputs; change systemState to ARMED break; case ARMED: /* FILLL in what it should be done here */ break; default: /* FILLL in what it should be done here */ } |
|
|
|
我可以看到更多的阶段,所以尝试一些类似的
EnUM告警状态{解除武装、武装、警报、警报、清除、未知系统状态; 系统状态=解除武装; (永远) { GETALLSENSORSOR(); 交换机(系统状态) { 解除武装: 案例武装: 案件告警: 等等 违约: } } 快乐编码 鲍勃 顺便说一下,这是我最喜欢的C手册之一的链接:HTTP://Pusith.GbDist.C.UK/C.Booo/ 以上来自于百度翻译 以下为原文 I can see a lot more stages, so try something like enum AlarmStates { DISARMED, ARMED, ALERTED, ALARMING, CLEARED, UNKNOWN} SystemState; SystemState = DISARMED; while(forever) { GetAllSensors(); switch(SystemState) { case DISARMED: case ARMED: case ALERTED: and so on default: } } Happy coding Bob Btw here is a link to one of my favorite C-manuals: http://publications.gbdirect.co.uk/c_book/ |
|
|
|
嗨,伙计们,
谢谢你的回复, 基本上,如果我有Lleung和鲍伯所说的话,那就有点像: EnUM告警状态{解除武装、武装、警报、警报、清除、未知系统状态; 系统状态=解除武装; (永远) { GETALLSENSORSOR(); 交换机(系统状态) { 解除武装: 检查键/ /将是类似的,检查键输入端口PIN是否高;如果(PRT1DR和AMP;0x01),例如端口1与FOB输入。如果是,清除警报输出,例如端口1.1, PRT1DR和;= ~0x02;/ /使报警输出低 系统状态=武装 断裂; 关于输入和输出数据,系统状态、武装、解除武装如何与微控制器的实际输入相关? 谢谢 顺便说一句。。感谢C手册链接鲍伯,IVE把它添加到书签中 以上来自于百度翻译 以下为原文 Hi guys, Thanks for your replies, So basically if i have what Lleung and Bob said then it'd be something like: enum AlarmStates { DISARMED, ARMED, ALERTED, ALARMING, CLEARED, UNKNOWN} SystemState; SystemState = DISARMED; while(forever) { GetAllSensors(); switch(SystemState) { case DISARMED: Check Keys /// would that be something like, check if key input port pin is high; if (PRT1DR & 0x01) for example port 1.0 with fob input. if so,clear alarm output, which for example is port 1.1, PRT1DR &= ~0X02; //make alarm output low SystemState= ARMED break; With regards to inputting and outputting data, how is SystemState, Armed, disarmed related to actual inputs from the microcontroller? thanks BTW.. thanks for the C manual link Bob, ive added it to bookmarks |
|
|
|
使用PSOC 1的开关和CASE或状态机的示例代码?
以上来自于百度翻译 以下为原文 any sample code using switch and case or state machines for PSoC 1? |
|
|
|
交换机和机箱都非常强大。
他们这样工作… 你有一个而且只有一个开关语句。 Switter语句检查变量的值,并执行依赖于THAT值的一组命令。 这样地: 状态(开关)(状态) 如果值=0中断,则执行此例0:/ /代码在此执行;如果值=0=0,则执行此例1:/ /此处执行代码;如果值=0中断,则执行此例2:/ /此处执行代码;默认值://此处执行代码,如果值不匹配以上任何一个。 } 因此,将程序的“状态”赋值为变量。 以上来自于百度翻译 以下为原文 Switch and Case are very powerful. They work like this... You have ONE and only ONE switch statement. The Switch statement examines the value of a variable and executes a set of commands dependent on theat value. Like this: int state; switch(state) { case 0: // code here is executed if the value == 0 break; case 1: // code here is executed if the value == 0 break; case 2: // code here is executed if the value == 0 break; default: // code here is executed if the value doesn't match any of the above. } So assign the 'state' of the program to variable. |
|
|
|
对于国家机器和C示例,谷歌和维基百科先生是一个令人愉快的信息来源。
在我的第一个编程手册(Ashton Tate)是读: 开始编写程序时最好的办法是关掉电脑。当你阅读你的程序时,我脑海里浮现的是你还不太清楚你想做什么。 我试着告诉你为每个州制定一个事件清单,让州***离开另一个州。这实际上是状态机的定义。事件是你的输入信号,哪些状态你应该收集在case块之外,并保存在一些变量中。 不推荐通过直接访问PRTXDR来设置信号,因为这可能会导致问题(关键字搜索“读取修改写入”或“影子寄存器”以获得更多信息)。我建议您使用一些LED组件与其相关的API。 鲍勃 以上来自于百度翻译 以下为原文 For state-machines and C-examples mrs Google and mr. Wikipedia are a cheerful source of information. In one of my first manuals for programming (by Ashton-Tate) was to read: The very best thing to do when starting to write a program is to switch off the computer. When reading your program thoughts it comes to my mind that you are not (yet) quite clear of what you want to do where. I tried to tell you to make a list of events for each state that will make the state to leave to another state. This actually IS the definition of a state-machine. The events are your input-signals whichs states you should collect outsides the case-block and save in some variables. Setting a signal by directly accessing the PRTxDR is NOT recommended because this might lead to a problem (make a keyword-search for "read-modify-write" or "Shadow-Register" to get more infos). I suggest you to use instead some LED-Components withtheir associated APIs. Bob |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2100 浏览 1 评论
1846 浏览 1 评论
3664 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1782 浏览 6 评论
1532 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
559浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
410浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
433浏览 2评论
379浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
905浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 14:06 , Processed in 1.313271 second(s), Total 114, Slave 97 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号