var dword collect_input=0
var dword received_input=0
var byte new_input

forever loop
  if serial_hw_data_read(new_input) then
    if (new_input>="0") & (new_input<="9") then
      collect_input=collect_input*10
      collect_input=collect_input+new_input-"0"
    end if
    if (new_input==13) | (new_input==10) then
      received_input=collect_input
      collect_input=0
    end if
  end if

end loop

It's meant as inspiration. I have not tested it, just typed it into the email 
editor.

Greets,
Kiste



Am Samstag, 24. April 2021, 08:49:33 MESZ hat majid ebru <[email protected]> 
Folgendes geschrieben: 





Thank all

But I need sample code for read.

Almost ,all documents use write code and I didn't saw read code.


On Saturday, April 24, 2021 at 10:58:36 AM UTC+4:30 vasile wrote:
> Majid, one good practice when you're testing communication between two 
> embedded systems (A and B) is to check each one with a terminal first. 
> 
> Assuming A is sending to B and B receives and does something on IO port, test 
> first the TX of A to the computer terminal, then RX of B from the computer 
> terminal. After that, only if each one works ok, connect TX/RX of A with B.  
> Some good free terminals for this job (search for:) Realterm, Teraterm, 
> Termite. You may also need a hardware converter which depends on your 
> computer (if you have a real COM port with RS232 levels or just an USB/RS232 
> with 3.3V or 5V levels). 
>                              
> This approach will protect you from a lot of trouble and make you understand 
> if a byte, a word, an ASCII or something else is truly sent/received and was 
> sent/received in the right order. 
> 
> Simplify your work by sending and receiving ASCII symbols first and then 
> understand all the used procedures from the libraries (this is mandatory to 
> understand which is your fault/misunderstanding or which is the software 
> bug... there are bugs in any software...:) ).
> 
> 
> 
> On Sat, Apr 24, 2021 at 8:36 AM Rob CJ <[email protected]> wrote:
>>  
>>  
>>  Hi Majid,
>> 
>>  
>> 
>> 
>>  If you want to send an integer value you indeed have to send it in bytes. 
>>But that thouls be faily easy with JAL.
>> 
>>  
>> 
>> 
>>  If have for example a variable of type word you can do the following
>> 
>>  
>> 
>> 
>>  var word my_word_variable
>> 
>>  var byte  my_byte_variable_low at my_word_variable
>> 
>>  var byte my_byte_high at my_word_variable + 1
>> 
>>  
>> 
>>  You can then send both 'my_byte' variables separately and in the other PIC 
>>you do the same, read the two bytes which are mapped to a word.
>> 
>>  
>> 
>> 
>>  Als see the documentation of the JAL compiler.
>> 
>>  
>> 
>> 
>>  Kind regards,
>> 
>>  
>> 
>> 
>>  Rob
>> 
>>  
>> 
>> 
>> 
>> ________________________________ 
>> Van: [email protected] <[email protected]> namens majid ebru 
>> <[email protected]>
>> Verzonden: vrijdag 23 april 2021 19:47
>> Aan: jallib <[email protected]>
>> Onderwerp: Re: NT: [jallib] How to send & receive data over medium distance 
>>  
>> 
>> 
>> 
>> Please help me 
>> 
>> 
>> 
>> I almost work with micro ,12 years ago .
>> 
>> 
>> 
>> 
>> Now I can't send / receive data?!
>> 
>> 
>> 
>> 
>> I should send and receive an integer(like adv value and ....) , but in 
>> serial_sw_data I just can send a byte ?!?!!!
>> 
>> And just read a byte with serial_sw_read(char)?!
>> 
>> 
>> 
>> 
>> I know that my kowlage about electronic is wake , but now I should do 
>> read&write data?!
>> 
>> 
>> 
>> 
>> Please guide me,🙏🙏🙏🙏🙏🙏🙏🙏
>> 
>> 
>> 
>> 
>>  
>> On Thursday, April 22, 2021 at 11:23:23 PM UTC+4:30 [email protected] wrote:
>> 
>> 
>>>  
>>>  
>>>  Hi Majid,
>>> 
>>>  
>>> 
>>> 
>>>  You have to provide more information. How do you know that they stopped? 
>>>Did you narrow down the code down to the minimal size to show that it fails? 
>>>If so you can share that code.
>>> 
>>>  
>>> 
>>> 
>>>  And to answer your other - not posted - comment. Due to the fact that you 
>>>use this group to answer trivial questions that you can find on the Internet 
>>>(which you should not do) and which are specific JAL or PIC related, your 
>>>posts are now moderated. Only posts which are relevant to this group are 
>>>passed on to the other group members.
>>> 
>>>  
>>> 
>>> 
>>>  Kind regards,
>>> 
>>>  
>>> Rob
>>> 
>>>  
>>> 
>>> 
>>> 
>>> ________________________________ 
>>> 
>>> 
>>> 
>>>  
>>> Van: [email protected] <[email protected]> namens majid ebru 
>>> <[email protected]>
>>> 
>>> 
>>>  
>>> Verzonden: donderdag 22 april 2021 20:19
>>> 
>>> 
>>>  
>>> Aan: jallib <[email protected]>Onderwerp: Re: NT: [jallib] How to 
>>> send & receive data over medium distance
>>> 
>>> 
>>>  
>>> Hi  
>>> 
>>> 
>>> 
>>> Please help me again😢😢😫😫🥺🥺🤔🤔
>>> 
>>> 
>>> 
>>> 
>>> When I connected two PICs together , everything is ok.
>>> 
>>> 
>>> 
>>> 
>>> But when disconnect port serial , both PICs hanged ?!?!
>>> 
>>> 
>>> 
>>> 
>>> Both micro stoped , and when connected again ,both micro work correctly?!
>>> 
>>> 
>>> 
>>> 
>>> In fact both micro stopped in line : if  serial_sw_read(char)) then block 
>>> ....
>>> 
>>> 
>>> 
>>> 
>>> And doesn't run other codes🤔🥺😫😢
>>> 
>>> 
>>> 
>>> 
>>> Why?!
>>> 
>>> 
>>> 
>>> 
>>> How should I do ?!
>>> 
>>>  
>>> On Wednesday, April 21, 2021 at 10:12:03 PM UTC+4:30 funlw65(Vasi) wrote:
>>> 
>>> 
>>>>  
>>>> The microcontroller boards that are used in Polish Universities are all 
>>>> equipped with (external - note for Majid) RS485 chips.  
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>  
>>>> On Wed, Apr 21, 2021 at 4:54 PM Rob CJ <[email protected]> wrote:
>>>> 
>>>> 
>>>> 
>>>>  
>>>>>  
>>>>>  
>>>>>  Hi Majid,
>>>>> 
>>>>>  
>>>>> 
>>>>> 
>>>>>  Please use Google to find out what RS485 and IIC is. Use the Jallib 
>>>>>group for issues with libraries and the compiler not for general questions 
>>>>>that you can easily find on the internet.
>>>>> 
>>>>>  
>>>>> 
>>>>> 
>>>>>  Thanks.
>>>>> 
>>>>>  
>>>>> 
>>>>> 
>>>>>  Kind regards,
>>>>> 
>>>>>  
>>>>> Rob
>>>>> 
>>>>>  
>>>>> 
>>>>> 
>>>>> 
>>>>> ________________________________ 
>>>>> Van: [email protected] <[email protected]> namens majid ebru 
>>>>> <[email protected]>
>>>>> Verzonden: woensdag 21 april 2021 15:47
>>>>> Aan: jallib <[email protected]>
>>>>> Onderwerp: Re: NT: [jallib] How to send & receive data over medium 
>>>>> distance 
>>>>>  
>>>>> 
>>>>> 
>>>>> RS485 is very powerful. 
>>>>> 
>>>>> 
>>>>> 
>>>>> But I don't how to implement in PIC?!?
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> Is i2c the same rs485?!
>>>>> 
>>>>> 
>>>>> 
>>>>>  
>>>>> On Wednesday, April 21, 2021 at 4:41:19 PM UTC+4:30 vasile wrote:
>>>>> 
>>>>> 
>>>>>>  
>>>>>>  
>>>>>>  
>>>>>> At 15m and 5V there is no problem with data sent in current. Using 
>>>>>> twisted wire cable is a good habit. 
>>>>>> 
>>>>>> From the EMI perspective twisted cable it is about half as good as a 
>>>>>> shielded cable and has the parasitic capacity quite low compared with 
>>>>>> the shielded cable.
>>>>>> 
>>>>>> RS485 (standard 32 loads) is feasible at 1Km and quite high speed. Still 
>>>>>> there is an issue with the ground line and requires good terminators.
>>>>>> 
>>>>>> Data goes either on A&B plus ground cable (three wires between Tx and 
>>>>>> RX) or just A&B (two wire cable) and ground connected to earth on the 
>>>>>> transmitter and receiver end. 
>>>>>> 
>>>>>> In the last configuration an issue is quite frequent caused by an offset 
>>>>>> (variable ground potential between TX and RX).
>>>>>> 
>>>>>> Also lightning is a problem for outdoor cables...and nothing help... 
>>>>>> :)... no matter how others will convince you to put three tranzorbs on 
>>>>>> each TX and RX  end.
>>>>>> 
>>>>>> happy communications! 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>  
>>>>>>  
>>>>>> On Wed, Apr 21, 2021 at 8:32 AM 'Oliver Seitz' via jallib 
>>>>>> <[email protected]> wrote:
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>  
>>>>>>  
>>>>>>>  Thanks for the additional information, 800m is something very 
>>>>>>>different from 20m ;-)
>>>>>>> 
>>>>>>> I can imagine that 20m at 5V ground-referenced is doable, but when 
>>>>>>> you're starting, better stick to the specifications and try your luck 
>>>>>>> when you have a bit of experience.
>>>>>>> 
>>>>>>> I myself am at a similar project, like 15 meter, and I want to use as 
>>>>>>> little standby current as possible, and no twisted pairs. It's 
>>>>>>> uni-directional, with constant-current pullup at the receiver and 
>>>>>>> optically isolated pulldown at the sender with 1200 baud... First test 
>>>>>>> of the concept in a few days ;-)
>>>>>>> 
>>>>>>> If standby current was of no concern, I'd use RS422 or RS485 
>>>>>>> drivers/receivers, true RS232 is old-fashioned and needs to many 
>>>>>>> components.
>>>>>>> 
>>>>>>> 
>>>>>>> Greets,
>>>>>>> Kiste
>>>>>>> 
>>>>>>> Am Mittwoch, 21. April 2021, 07:02:46 MESZ hat vsurducan 
>>>>>>> <[email protected]> Folgendes geschrieben: 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> Oliver, I remember the problems I had with an EIA232 with +/-8V output 
>>>>>>> running at 800m at 9600bps. Everything works until due the transceiver 
>>>>>>> heating the voltage dropped at +/-7.6V...:)
>>>>>>> The length is given by the voltage at the level converter of the 
>>>>>>> transmitter output. All level converters with charge pumps are not able 
>>>>>>> to give more than +/-8V...+/-10V in the happiest circumstances.
>>>>>>> Oldest/goldest EIA232 worked at +/-25V up to 2km.
>>>>>>> For 20m you do noy need any level converter at the output of your PIC, 
>>>>>>> just a twisted pair RX-GND TX-GND (CAT5 ethernet cable is perfect) and 
>>>>>>> an open collector transmitter ( a gate) with pull-up resistor in the 
>>>>>>> receiver end (at 20m distance from the transmitter).
>>>>>>> However Majid,  I think you need first to learn jal and for that there 
>>>>>>> is a learning curve which has to be passed....
>>>>>>> Please start with the examples, compile them, make them run, modify 
>>>>>>> them as you wish and post only when nothing works for you after three 
>>>>>>> days of trying...this will help you more than you may believe right 
>>>>>>> now...
>>>>>>> best wishes
>>>>>>> 
>>>>>>> On Wed, Apr 21, 2021 at 7:28 AM 'Oliver Seitz' via jallib 
>>>>>>> <[email protected]> wrote:
>>>>>>>> Hi Majid,
>>>>>>>> 
>>>>>>>> SPI is designed for centimeters, I don't think it can work reliably 
>>>>>>>> over 20 meters.
>>>>>>>> 
>>>>>>>> RS232 at 9600 baud is ok for 150 meters, if you're using real RS232 
>>>>>>>> drivers and receivers like from the MAX232 series. The PIC controller 
>>>>>>>> does not have RS232, it has a usart which handles the NRZ protocol. 
>>>>>>>> This protocol is best known as being used by the RS232 interface. 
>>>>>>>> Therefore the protocol itself is commonly (but wrongly) referred to as 
>>>>>>>> "RS232"
>>>>>>>> 
>>>>>>>> RS232 uses negative voltages as a symbolic "1" and positive voltages 
>>>>>>>> for "0". At the receiving side, the voltage must at least go higher 
>>>>>>>> than +3V for "0" and lower than -3V for "1". At the sending side, 
>>>>>>>> voltages from up to +15V and down to -15V are used.
>>>>>>>> 
>>>>>>>> So, to answer your question in two simple sentences: RS232 is ok for 
>>>>>>>> the job. But RS232 is not what comes out of the controller.
>>>>>>>> 
>>>>>>>> Greets,
>>>>>>>> Kiste
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Am Dienstag, 20. April 2021, 21:56:34 MESZ hat majid ebru 
>>>>>>>> <[email protected]> Folgendes geschrieben: 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> can i ask another  question??
>>>>>>>> 
>>>>>>>> if it is 20 meter distance between PICs , i should use RS232 or SPI?
>>>>>>>> 
>>>>>>>> so sorry and thanks a lot
>>>>>>>> 
>>>>>>>> ‪majid ebru‬‏ در تاریخ سه‌شنبه ۲۰ آوریل ۲۰۲۱ ساعت 
>>>>>>>> 
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "jallib" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>>>>> an email to [email protected].
>>>>>>>> To view this discussion on the web visit  
>>>>>>>> https://groups.google.com/d/msgid/jallib/1697687282.4677348.1618979276333%40mail.yahoo.com.
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "jallib" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>>>> an email to [email protected].
>>>>>>> To view this discussion on the web visit  
>>>>>>> https://groups.google.com/d/msgid/jallib/CAM%2Bj4qtaBjojssk_HHFK1M2dhhL9CNNf3mygd1F3nH0B5bck9A%40mail.gmail.com.
>>>>>>> 
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "jallib" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>>>> an email to [email protected].
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>  
>>>>>>  
>>>>>>>  To view this discussion on the web visit  
>>>>>>>https://groups.google.com/d/msgid/jallib/1020737915.4719521.1618983169979%40mail.yahoo.com.
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "jallib" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>>> email to [email protected].
>>>>> To view this discussion on the web visit  
>>>>> https://groups.google.com/d/msgid/jallib/22c899b2-b475-404d-9982-fb4e9ffe3169n%40googlegroups.com.
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "jallib" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>>> email to [email protected].
>>>>> 
>>>> 
>>>> 
>>>>  
>>>>>  To view this discussion on the web visit  
>>>>>https://groups.google.com/d/msgid/jallib/AM0PR07MB624188EEE1255C4E45C31F80E6479%40AM0PR07MB6241.eurprd07.prod.outlook.com.
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> 
>>>> Vasi
>>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "jallib" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to [email protected].
>>> 
>>> 
>>> 
>>>  
>>> To view this discussion on the web visit  
>>> https://groups.google.com/d/msgid/jallib/ad446bf9-5eab-4168-8326-b33f2a02c0f5n%40googlegroups.com.
>>> 
>>> 
>>> 
>> 
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jallib" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit  
>> https://groups.google.com/d/msgid/jallib/187dbbf2-8c1b-43c2-ac9b-ce320495f60fn%40googlegroups.com.
>> 
>> 
>>  
>>  
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jallib" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>  To view this discussion on the web visit 
>>https://groups.google.com/d/msgid/jallib/AM0PR07MB6241CB67E4CBAE8CFD01D0D0E6449%40AM0PR07MB6241.eurprd07.prod.outlook.com.
>> 
> 


-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/b32a5de8-117c-4c73-a771-5ba9a493b45cn%40googlegroups.com
.

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/1500955534.640246.1619247418355%40mail.yahoo.com.

Reply via email to