Multiple Branch Instruction of PSoC5LP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
suto_2664507
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

user_13463998@Dear Sir,

Regarding PSoC 5 LP and C language, it is still a beginner and I am in trouble because I can not do a full-scale program.
I hope to be able to complete the project as soon as possible with an effort.

In this community, Mr.Tanaka thanked you very much for interrupt handling.

This time, I gathered various samples and read manuals, but I came to learn advice and lectures by the members, because I am a beginner, I do not know what is good and what to do.

First of all, it was possible to set the mode in the switch-case statement to 0 → 1 → 2 → 3 → 4 → 5 → 0 by MODE_SW interrupt.
There is a tact switch called UP and DOWN on the outside, and I want to be able to use it when mode is 1 and 2.
It counts up or counts down every time it is pressed, but if you press and hold it for a long time it will not count how you can count up and count down fast.
In mode 1, the upper limit value is set, while in mode 2, the lower limit value is set, but I want to save it to EEPROM even when the power is turned off.

The setting can be changed, but once the upper limit of mode 1 and the lower limit of mode 2 are decided, is there any way to turn on the external LED?
I tried it with hardware, but with the combination of LUT, counter, and comparator, I will not do the function as specified.

After all it may be impossible unless you are accustomed to handling C language.

Then later I noticed that unless the MODE_SW button is pressed, you will also need to check that the UP and DOWN buttons are not pressed.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

鈴木様、

先のヴァージョンでは上限値、下限値到達時の OVER, UNDER の表示が適切ではなかったので手直しをしました。

PDS05 を想定して最大値を 5.00 上限、下限の初期値を 最大値/2 と変更しました。

また、main() が育ちすぎて来たので各 mode 毎の処理に分割しました。

char str[] は char buf[] に統合しました。

その他、コメント、プロトタイプ宣言を少し整理しました。

このスレの最初の仕様はほぼ実装されているのではないかと思います。

ここまでのところで、EEPROMへの書き込み、読み出しを除く仕様書に書かれていた処理を行う為の部品は、

ほぼそろったのではないかと思いますので、後はご自身でも加筆・修正いただけるのではないかと思います。

ご不明なところが発生しましたなら、その部分を切り出して質問スレッドを新たに立てていただけるとよいのではないかと思います。

個人的なご連絡が必要な場合は Community の Private Message にてご連絡ください。

以上

11-Feb-2019

田中 基夫

aka moto

View solution in original post

0 Likes
11 Replies
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Suzuki-san,

May be this sounds hard, but Community is supposed to help each other for individual technical difficulty,

and not a place to throw a specification/requirement and let others develop a system for you.

So if you say

> Regarding PSoC 5 LP and C language, it is still a beginner and I am in trouble because I can not do a full-scale program.

The correct answer will be

"Hire or pay a professional programmer to do it."

Having said (written) that, I'd recommend you to ask  a question in a small size theme and one by one.

So in the last thread you asked how to handle key interrupt to proceed a state machine.

And in this thread you sound asking

(1) How to implement sub state(s)

    A switch called MODE_SW steps mode from 0 -> 1 -> ... -> 5 -> 0 (done in the previous thread)

    A switch called UP increases the value of

    (1.1) in mode 1 upper limit

    (1.2) in mode 2 lower limit

    A single click will increases the value one step wise

    Long push causes fast (continuous) increase

    when the value hits the upper limit an external LED is turned on. (3)

    A switch called DOWN decreases the value of

    (1.3) in mode 1 upper limit

    (1.4) in mode 2 lower limit

    A single click will decreases the value one step wise

    Long push causes fast (continuous) decrease.

    when the value hits the lower limit an external LED is turned on. (3)

(2) How to save current set-up to EEPROM

(3) How to turn on an external LED when setting value reached to its extreme

Best Regards,

10-Feb-2019

Motoo Tanaka

P.S. I modified previous thread's project as recently I learned that some pins in CY8CKIT-059 is not good for high frequency input/output as the pin is connected to the GND via C.

problem with op-amp loading input signal

CY8CKIT_5LP_C_Pins.JPG

I changed pins to avoid these pins and I connected a cathode-common 7SEG LED.

With the attached project the program seems to be displaying the value reported to the serial.

000-TeraTerm-log.JPG

IMG_3387S.JPG

0 Likes

Mr.Tanaka

Allow me to thank you for the other day's advice and design aid.

What you said is right is correct, and I confusing business contract with this community.

I am very aware of that.

I was just thinking about that.

I would like you to take on that work for a fee.

There are two reasons.

The first : I have not experienced development using PSoC around here.

and second : My development predecessor died at the end of last year.

It is because I will take over with no experience with PSoC.

The other day you have done a very wonderful assistance.

I'm so grateful.

I searched Mr.Tanaka's website or email address, but I did not understand it.

So, I decided to ask you again in this community.

Will you undertake the work?

I was surprised.

You reproduced the case using seven segments!

I could cry for joy.

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Suzuki-san,

So after all we can do what we can within our time budget.

Anyway after a round trip to Akihabara, following is result of my weekend day 😉

As I wanted to use external tact switches, I changed SW to P0[3], please return it to P2[2] if you need.

Meantime I added debouncer components along with a FreqDiv.

And note that the stateMachine and main loop were somewhat modified 😜

IMG_3388S.JPG

002-TeraTerm-log.JPG

moto

0 Likes
lock attach
Attachments are accessible only for community members.

Dear Mr.Tanaka

I would

appreciate your cooperation.

But,please bill me for your expenses.

I checked it from my PC at home from the beginning, but the following

errors will appear at build time.

“Build error: Hex file generation step failed, see output window for more information.”

On a 32 bit PC, it may be insufficient.

I will bring a PC from the company early in the morning tomorrow and check it.

However, I am surprised because you will instantly complete this specification.

Are there two correction points? p0.3 changed to p0.6, p2.2 changed to p0.3?

I am sorry for the specification because of my lack of explanation.

Is it better to explain it now than to add it later? !

There are 15 types of this pressure monitor.

This time, it is a specification of 5MPpascal.So, the range of 0.8 V to 4V corresponds to 0. 00-5.00 MPascal.

The display of Mode1, 2, 3 and 4 shows 1/2 of the rated pressure (=2.50 MPascal) when the power is turned on.

Attached is the specification created by the predecessor.

Thank you.

Best Regards,

Suzuki

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

鈴木様、

現時点では、あくまでもボランティアとしてのコミュニティ活動ですので

料金を申し受けるわけにはまいりません。

同時に、内容についての責任は免除をお願いいたします。

最後に添付された仕様書はまだ拝見させていただいておりませんが

このスレッドの最初に書かれていた仕様は概ね満たせたと思う版を添付します。

なお、mode 1 と mode 3, mode 2 と mode 4 の違いが理解できなかったため

とりあえず mode 1 と mode 2 に単発押し、長時間押しの機能と

上限下限のチェックを入れてみました。

必要に応じて mode1, mode2 の部分を mode3, mode4 にコピーしていただければ

同様の動きをするものと思われます。

003-TeraTerm-log.JPG

ソース中にあるように上限、下限の初期値を定格値の半分にすべきか迷った為

とりあえずそれらしい上限値と下限値を代入して動き始めるようにしてあります。

P2_2 を P3_0 に変更したのは、モード切替も外部のタクトスイッチを使用したかったためです。

またP3_0 を P0_6 に変更したのは、P3_0 には基板上にコンデンサがつけてあって

速度の速い信号では、ローパスとして働いてしまうため P0_6 に変更しました。

P0_3 についている C13 (1.0uF) を外して使われるのであればこの問題は無視して良いと思います。

以上

11-Feb-2019

田中 基夫

aka moto

P.S. でも、お役にたてたなら Helpful, 回答として正しければ Correct Answer をつけていただけると大変うれしいです。

P.S.2 上限値 2.5 のつもりでやってしまいました... ソースの先頭の方にある定義を変更していただければ 5.0 でもいけると思います。(^_^;;

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

鈴木様、

先のヴァージョンでは上限値、下限値到達時の OVER, UNDER の表示が適切ではなかったので手直しをしました。

PDS05 を想定して最大値を 5.00 上限、下限の初期値を 最大値/2 と変更しました。

また、main() が育ちすぎて来たので各 mode 毎の処理に分割しました。

char str[] は char buf[] に統合しました。

その他、コメント、プロトタイプ宣言を少し整理しました。

このスレの最初の仕様はほぼ実装されているのではないかと思います。

ここまでのところで、EEPROMへの書き込み、読み出しを除く仕様書に書かれていた処理を行う為の部品は、

ほぼそろったのではないかと思いますので、後はご自身でも加筆・修正いただけるのではないかと思います。

ご不明なところが発生しましたなら、その部分を切り出して質問スレッドを新たに立てていただけるとよいのではないかと思います。

個人的なご連絡が必要な場合は Community の Private Message にてご連絡ください。

以上

11-Feb-2019

田中 基夫

aka moto

0 Likes
lock attach
Attachments are accessible only for community members.

田中さん

お世話様です、鈴木で御座います。

会社に置いてあるノートPCが本日取りに行きましたが階段の工事で業者が入っており

3階の自分の部屋まで上がれず、断念して戻ってきました。

仕方が無く、家内のPCを借りて田中さんの作成して下さったプログラムをDLしまして、

何とかコンパイルまで出来ましたが、状態が前回の物と違っていますね。

TeraTermでモニターはOKですが、SWの変更したピン、P0.3は押しても一向に割り込みが

かからなくなりました。

また7SEGMENTのCOM3はP0.6に変更しましたがSEGMENTが点灯しません。

COM3ですから4桁7SEGMENTの右端が消灯しています。

CONFIG見ると、COM0~3がアクティブLOWになっていましたが、これはアクティブHIGH

です。a~gとdotは負論理ですので、アクティブLOWが正解です。

スケマチック変更だけでは治りませんね?

MODEが左端で切り替わるのですが、それが確認出来ないので、UPとDOWN機能も確認する

事が出来ませんでした。

変更箇所2つをもう一度チェックし、ハード的に何が悪いのか追求してみます。

なお、田中さんのプログラムを明日から勉強と言いますか学びの時間に充てたいと思います。

お休みの日も小生の為に時間を割き、労して下さって、感謝に堪えません。

本当に有り難う御座います。

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

鈴木様、

オフィスに転がっていた7SEGがカソードコモン (SEGが High Active, COM が Low Active)のものであったためそのような設定に変更して使用しておりました。幸い秋葉原ではカソードコモンの物とアノードコモンの物を購入してきてありますので、私の方も明日動作確認をしてみたいかと思います。変更はスケマティック上の LED_Drive_1 のコンフィグと LED_Drive_1 に接続されている 二つのピン Pin_Seg と Pin_Com の初期値を変えることで対応が可能かと思います。以下、それぞれ現状と変更を添付します。

LED_Driver_1 現状

※ リフレッシュレートが200Hz 以上でしたので、ちょっと速いかなと思い
 70Hz に変更してみましたが、Actual は同じままだったようですので
 ここの変更は不要かと思います。

000-LED_Driver_1.JPG

LED_Driver_1 変更

001-LED_Driver_1.JPG

Pin_Seg 現状

002-Pin_Seg.JPG

Pin_Seg 変更

003-Pin_Seg.JPG

Pin_Com 現状

004-Pin_Com.JPG

Pin_Com 変更

005-Pin_Com.JPG

COM3で不都合が起きている場合、

SW を元の P2[2], COM3 をP0[3] に戻してお試しいただけないでしょうか?

周波数応答が悪くなるだけで、全く点灯しないという状態にはならないのではないかと思います。

また、一回押しと連続押しの動きですが、

お送りしたヴァージョンでは下記のような処理にしていましたが

=====================

        if (UP_Pressed_Duration < UP_DURATION_THRESHOLD) {

            upper_limit += SLOW_UP_STEP ;

        } else {

            upper_limit += FAST_UP_STEP ;

        }

=====================

以下の処理の方が好ましいかもしれません。

私も明日試してみたいかと思います。

=====================

        if (UP_Pressed_Duration == 0) { // 初回だけ

   upper_limit += SLOW_UP_STEP ;

        } else  if (UP_Pressed_Duration < UP_DURATION_THRESHOLD) {

             UP_Pressed_Duration++ ;

        } else {

            upper_limit += FAST_UP_STEP ;

        }

        ...

//         UP_Pressed_Duration++ ;

=====================

以上

11-Feb-2019

田中 基夫

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

鈴木様、

昨夜、不思議な現象が発生した理由がわかりました。

先のメッセージで私が P0[3] を P3[0] とミスタイプしていました。

オリジナルのピン配置では

COM3 P0[3]

SW    P2[2]

となっていましたが、

P0[3] にはコンデンサが接続されている

P2[2] は基板上のスイッチなのでジャンパ接続後に触りにくい

等の理由で

COM3 P0[6]

SW    P0[3]

との変更をしておりました。

以上から、

Design01_19212A : SW P0[3], COM3 P0[6]

Design01_19212B : SW P2[2], COM3 P0[3]

としたプロジェクトを添付します。

どちらのプロジェクトもジャンパの接続を上記に合わせることにより

アノードコモンの7SEGで正常に動作していることを確認しております。

以上

12-Feb-2019

田中 基夫

0 Likes

田中様

お世話様で御座います。

2件のソフト修正版を試してみました。

①Design01_19212A : SW P0[3], COM3 P0[6]

 配線もこの通りに変更しました。

 ところが、7segment右から1桁目と2桁目が消灯状態でした。

 よって、TeraTermでモニターしましたが、割り込みはかかりませんでした。

②Design01_19212B : SW P2[2], COM3 P0[3]

 配線もこの通りに変更しました。

 ところが、7segment右から2桁目Com2が消灯状態でした。P0(5)が?

 表示は”00.X0”(Xは消灯)です。この状態はmode0ですが、左端のCom0が”0”となります。

 mode1-mode2

 SWを押すと確実に割り込みがかかります。素晴らしい!今までのバージョンは何回か押さないと

 割り込みがかかりませんでした。

 ところが、表示は”02X0”です。mode表示の”1”が左端の7segmentに出力されていませんでした。

 そしてドットが消灯しておりました。おそらく”0250”と表示されているのでしょう。

 仕様は本来”12.50”が正解です。

 UP・・・SWを1回ずつ押す度に1桁目に数がインクリメントしますが、2桁目はモニターで確認すると

 桁上げされていますので、動作はOKです。

 SW長押しにすると、速くカウントアップし、モニターでは”05.00”でUpper limitを確認出来ました。

 外部LED01がこの時点灯しておりました。(根拠無し)と謳われているのに笑ってしまいました。

 本来はEXCEL添付した仕様書での、4個の7segmentが真ん中のsegmentがフラッシュさせたいのです。

 DOWN・・・SWを1回ずつ押す度に1桁目に数がディクリメントしますが、2桁目はモニターで確認すると

 桁下げされていますので、動作はOKです。

 SW長押しにすると、速くカウントダウンし、モニターでは”00.00”でLower limitを確認出来ました。

 外部LED02がこの時点灯しておりましたが、下限警報は必要無しと言うことで点灯させなくてもOKです。

 mode2で下限値設定しますので、表示は”22.50”と最初表示されてなければなりません。

 なお、田中さんのソフトにあって、上限値、下限値は私でもパラメータ変更すれば大丈夫ですね?

 今回は圧力モニターPDS05(5MPascal)タイプですので、mode1~mode4までは基準値2.5MPascalで

 宜しいです。

 mode1と2の組合せで外部のフォトリレーSWITCH_OUT_1 P2(1)とLED01がONします。これはmodeが

 0→1→2→3→4→5→0と最初のmode0に戻った時点で設定がONされ、EEPROMにSAVEされます。

 ですので、電源をパワーオンリセットしてもmode1と2の設定値は保持していなければなりません。

 mode3-mode4

 mode3と4の組合せで外部のフォトリレーSWITCH_OUT_2 P2(7)とLED02がONします。これはmodeが

 0→1→2→3→4→5→0と最初のmode0に戻った時点で設定がONされ、EEPROMにSAVEされます。

 ですので、電源をパワーオンリセットしてもmode3と4の設定値は保持していなければなりません。

 mode1と2の組合せと動作は同じですが、mode3と4の設定値=mode1と2の設定値となりません。

 

 mode5

 これは4桁7segment全て消灯します。現状のままで正解です。

 修正は、Design01_19212B : SW P2[2], COM3 P0[3]の路線で良いと思います。 

 ほぼ完成に近いところまで出来上がっておりますね。

 圧力値が違う物に関しては、田中さんのソースコードを引用し、とにかく自分が理解出来るまで勉強したいと

 思います。

 有り難う御座います。

 

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

鈴木様、

7SEG の点灯不具合については下記のピンリストと配線をご確認いただけないでしょうか?

先のメッセージにもあったように、コンデンサのつながっているピンを他のピンに移している部分がございます。

001-Pin_List.JPG

本日版のプロジェクトを添付します。

moto

0 Likes